npx is not working after installing node 16.3.0 on ubuntu 21.10 with nvm

Viewed 762

I installed node js using nvm first I installed version 17.1.0 I had some problems with node-gyp , so I downgraded to 16.3.0 (current lts) . but every script I am runing using npx causeing me an error

spawn <package npx need to run> ENOENT

If I am installing the package globaly it will work only in the same terminal session

1 Answers

I understand this may not be the best solution but I have been having problems with nvm and versions not actually switching So I would start by looking at your current node version

node -v

And check your npx version with

npx -v

Anything above node 5.2 should have npx already installed but on the off chance that it isn't you can install it with

npm install -g npx

If this is all installed, theoretically it should all work but I understand you are having issues. This is not an ideal solution, but you could

npm i <package-name>

npm run <package-name>

Hopefully this at least allows you to continue working while finding out why npx isn't working on your machine.

Another npm version manager alternative is n if you'd like to check them out and see if you have any better luck installing and changing node versions https://www.npmjs.com/package/n

Related