wgallop
wgallop

Reputation: 167

Express command not found after setting installing globally

When I run sudo npm install -g express-generator:

/Users/myname/npm/bin/express -> /Users/myname/npm/lib/node_modules/express-generator/bin/express-cli.js
/Users/myname/npm/lib
   └── [email protected]

And when I run express:

express not found

Also, I thought it was interesting that when I run which npm:

/usr/local/bin/npm

That is the path.

It seems that whenever I try to install something like yeoman or this express generator globally, it never works.

It should also be noted that I am on an Mac running zsh.

Upvotes: 0

Views: 984

Answers (3)

thomann061
thomann061

Reputation: 639

This affects Homebrew users using Node.js & npm

When you install Node.js using Homebrew it does not put npm on the PATH for you, however it suggests that you should do so.

Homebrew doesn't modify the user's environment or dotfiles. However, brew install node does print a message suggesting the user add that path to their PATH.

Source

Upvotes: 0

wgallop
wgallop

Reputation: 167

Running this in the command line:

export PATH=/usr/local/bin/npm:$PATH

Fixed the issue...for now. I'm not totally sure why that worked.

Upvotes: 0

Behrooz
Behrooz

Reputation: 2371

Most likely your npm bin directory is not in the path. Try to list the files in that directory by ls -l /usr/local/share/npm/bin/.

If you find the express file, you can add that directory to the path by export PATH=/usr/local/share/npm/bin:$PATH. If not, most likely something went wrong with your installation and you can try installing the module again.

Upvotes: 1

Related Questions