2

My npm in terminal isn't working after Mavericks update.

node app.js works well and runs my app, but when I run npm followed by anything I get -bash: npm: command not found. I know this question has been asked before here:

Global installation with npm doesn't work after Mac OS X Mavericks update and How do I install a module globally using npm? and npm not working after reinstalling Mac OS X , but none of the answers resolved my situation.

$ echo $PATH /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/mongodb/bin

Community
  • 1
  • 1
Squirrl
  • 4,909
  • 9
  • 47
  • 85

2 Answers2

0

How did you install node.js ? typically it comes bundled with both node and npm, where both are in the same directory. My suggestion is to remove your current install(s) and do the following with just works.

to install nodejs and npm as yourself NOT root do these commands (OSX/linux) :

parent_dir=${HOME}/bin_xxxx  #  replace bin_xxx with something specific
                             #  to node release like bin_v0.10.31

mkdir ${parent_dir}

download source from : http://nodejs.org/download/

cd node-v0.xxxx

./configure   --prefix=${parent_dir}/nodejs

make -j8
make install

which puts it into dir defined by above --prefix

export PATH=${parent_dir}/nodejs/bin:$PATH

define environment variable NODE_PATH so node can find dir for modules otherwise npm install xxx will put newly installed module into dir in curr dir :

export NODE_PATH=${parent_dir}/nodejs/lib/node_modules

do above AND use syntax : npm install -g some_cool_module always use the -g for global so it gets installed into dir $NODE_PATH and not your $PWD

nodejs install gives you npm as well :

ls -la ${parent_dir}/nodejs/bin
Scott Stensland
  • 26,870
  • 12
  • 93
  • 104
0

For Debian, after installing node do following

curl -k -O -L https://npmjs.org/install.sh
ln -s /usr/bin/nodejs /usr/bin/node
sh install.sh
pacholik
  • 8,607
  • 9
  • 43
  • 55
Shaharyar Zafar
  • 104
  • 1
  • 8