Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM Won't Run After Upgrade

Tags:

node.js

npm

macos

I've been using node .4x and npm, and decided to upgrade to .67. Oh boy.

I'm on Mac OSX--new to it.

When I type npm I get

-bash: /usr/bin/npm: No such file or directory 

echo $PATH shows a lot of stuff...some redundancies.

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin:/Users/me/.rvm/bin:/usr/local/bin:/usr/local/:/usr/local/bin:/usr/local/bin/npm:/usr/local/bin/:/usr/local:/usr/local/bin:/usr/local/ 

I've tried a number of different installations, and likely should clean it up, which I don't know how to do :)

Any insights?

like image 228
bear Avatar asked Jan 20 '12 00:01

bear


People also ask

Why npm install is not running?

If your npm is broken: On Mac or Linux, reinstall npm. Windows: If you're on Windows and you have a broken installation, the easiest thing to do is to reinstall node from the official installer (see this note about installing the latest stable version).

How do I force npm to run?

Run npm update -g npm. Execute this command by running the command prompt as Administrator npm install -g windows-build-tools. Run npm install inside the project folder where the package. json file is located, if it doesn't work run: npm install --force.

Does upgrading node upgrade npm?

In Windows, you can simply download the newest version of node and install it. It'll upgrade both node and npm.


1 Answers

If npm is no longer installed in /usr/bin/npm, then chances are good bash(1) has hashed the executable name. The hashing saves repeated searches of all directories in your PATH every time you execute common programs. Since programs almost never change directories, this is usually a great idea.

To test, run hash -r. This will cause bash(1) to forget all its mappings. (This is harmless -- it starts up with no mappings and grows them over time.) If I was right, your npm will execute the correct executable wherever it lives.

like image 178
sarnold Avatar answered Sep 28 '22 01:09

sarnold