"/snap/bin/npm: No such file or directory" after `snap remove node` and installing node via apt

I unstalled node through snap and was getting an error about permission denied for the directory /nonexistent, which this thread says is an NPM issue.

After I removed node from snap, and installed it using apt, I am getting the error bash: /snap/bin/npm: No such file or directory.

I have to fully qualify the npm path every time I want to run npm: sudo /usr/bin/npm i package.

How can I stop snap from taking over the NPM path? My path contains /snap/bin, which I would like to keep. But not for NPM.

Just launch a new terminal, or run bash in your existing terminal to refresh the path to npm.

2 Likes

Oh my gosh… I’m an idiot. Thank you.

Or to fix it in an existing shell, run hash -d npm. That will tell Bash to forget the cached path of the given command.