im_benton im_benton - 1 year ago 196
Node.js Question

Global Node modules not installing correctly. Command not found

I am having a problem installing global node modules and everything I find online says the solve is just adding -g. Which is not the problem. I believe it's a linking issue or wrong directory issue.

Here is what I do:

$ npm install -g express
npm http GET
npm http 304
npm http GET
npm http GET
...downloads correctly

$ express myapp
bash: express: command not found

However when I run the direct link location to express it works:

$ /usr/local/share/npm/bin/express myapp

create : myapp
create : myapp/package.json
create : myapp/app.js
... Builds app correctly

Where the module is:

$ which node
$ node -pe process.execPath
$ npm link express
/Users/bentonrr/Development/Personal/node_modules/express -> /usr/local/share/npm/lib/node_modules/express

In my .bash_profile I have:

export PATH=/usr/local/bin:$PATH
export NODE_PATH=/usr/local/lib/node_modules:/usr/local/lib/node

Do I need to change my Node environment to download to correct folder? Is something not linking correctly? I am lost..


Other Specs:

$ node --version
$ npm --version
$ brew --version
OSX Version 10.8.2

Answer Source

Add /usr/local/share/npm/bin to your PATH (e.g., in .bashrc).

For more info, see npm help npm:

global mode: npm installs packages into the install prefix at prefix/lib/node_modules and bins are installed in prefix/bin.

You can find the install prefix with npm get prefix or npm config list | grep prefix.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download