The best place to *find* answers to programming/development questions, imo, however it's the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but again, a great reference for *finding* answers.

My Music (Nickleus)

20150715

[SOLVED] installing Node.js: npm not found: Mac OS X Installer (.pkg) Universal

i wanted to test out Node.js, so i downloaded the Mac OS X Installer (.pkg) Universal (specifically, node-v0.12.7), n the installation completed fine, n it said that node n npm were installed here:

/usr/local/bin/node
/usr/local/bin/npm

and PATH contains that path:
echo $PATH

output:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin...

but when i try updating npm:
sudo npm update -g npm

i get:
sudo: npm: command not found

and "ls" confirms that it isn't installed:
sudo ls -la /usr/local/bin

output:
...
lrwxr-xr-x   1 nick  admin        32 May  2  2014 mvnyjp -> ../Cellar/maven/3.2.1/bin/mvnyjp
-rwxr-xr-x   1 root  admin  36046288 Jul 10 00:51 node
lrwxr-xr-x   1 root  admin        45 May 12 15:40 protractor -> ../lib/node_modules/protractor/bin/protractor
-rwxr--r--   1 nick  staff      2757 Mar  2 12:11 pstorm
...

Chris Barber reports that /usr/local/bin/npm should be a symlink to /usr/local/lib/node_modules/npm/bin/npm-cli.js

i can run npm through node:
node /usr/local/lib/node_modules/npm/bin/npm-cli.js -v

outputs:
2.11.3

"ls"-ing "lib":
ls -la /usr/local/lib

shows a curious ownership/permission setting for "node_modules" directory:
drwxr-xr-x   6 24561  wheel     204 May 18 09:57 node_modules

to fix this, the solution seems to be as simple as creating that symlink:
sudo ln -s /usr/local/lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm

i tried updating npm again:
sudo npm update -g npm

this time it outputs:
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
npm@2.13.0 /usr/local/lib/node_modules/npm

:)