Instantly share code, notes, and snippets.

Embed
What would you like to do?
Instructions on how to fix npm if you've installed Node through Homebrew on Mac OS X or Linuxbrew

Fixing npm On Mac OS X for Homebrew Users

Installing node through Homebrew can cause problems with npm for globally installed packages. To fix it quickly, use the solution below. An explanation is also included at the end of this document.

Solution

This solution fixes the error caused by trying to run npm update npm -g. Once you're finished, you also won't need to use sudo to install npm modules globally.

Before you start, make a note of any globally installed npm packages. These instructions will have you remove all of those packages. After you're finished you'll need to re-install them.

Run the following commands to remove all existing global npm modules, uninstall node & npm, re-install node with the correct defaults, configure the location for global npm modules to be installed, and then install npm as its own pacakge.

rm -rf /usr/local/lib/node_modules
brew uninstall node
brew install node --without-npm
echo prefix=~/.npm-packages >> ~/.npmrc
curl -L https://www.npmjs.com/install.sh | sh

Node and npm should be correctly installed at this point. The final step is to add ~/.npm-packages/bin to your PATH so npm and global npm packages are usable. To do this, add the following line to your ~/.bash_profile:

export PATH="$HOME/.npm-packages/bin:$PATH"

Now you can re-install any global npm packages you need without any problems.

Explanation of the issue

If you're a Homebrew user and you installed node via Homebrew, there is a major philosophical issue with the way Homebrew and NPM work together. If you install node with Homebrew and then try to do npm update npm -g, you may see an error like this:

$ npm update npm -g
npm http GET https://registry.npmjs.org/npm
npm http 304 https://registry.npmjs.org/npm
npm http GET https://registry.npmjs.org/npm/1.4.4
npm http 304 https://registry.npmjs.org/npm/1.4.4
npm ERR! error rolling back Error: Refusing to delete: /usr/local/bin/npm not in /usr/local/lib/node_modules/npm
npm ERR! error rolling back     at clobberFail (/usr/local/Cellar/node/0.10.26/lib/node_modules/npm/lib/utils/gently-rm.js:57:12)
npm ERR! error rolling back     at next (/usr/local/Cellar/node/0.10.26/lib/node_modules/npm/lib/utils/gently-rm.js:43:14)
npm ERR! error rolling back     at /usr/local/Cellar/node/0.10.26/lib/node_modules/npm/lib/utils/gently-rm.js:52:12
npm ERR! error rolling back     at Object.oncomplete (fs.js:107:15)
npm ERR! error rolling back  npm@1.4.4 { [Error: Refusing to delete: /usr/local/bin/npm not in /usr/local/lib/node_modules/npm] code: 'EEXIST', path: '/usr/local/bin/npm' }
npm ERR! Refusing to delete: /usr/local/bin/npm not in /usr/local/lib/node_modules/npm
File exists: /usr/local/bin/npm
Move it away, and try again. 

npm ERR! System Darwin 13.1.0
npm ERR! command "/usr/local/Cellar/node/0.10.26/bin/node" "/usr/local/bin/npm" "update" "npm" "-g"
npm ERR! cwd /Users/dan/Google Drive/Projects/dotfiles
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! path /usr/local/bin/npm
npm ERR! code EEXIST
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/dan/Google Drive/Projects/dotfiles/npm-debug.log
npm ERR! not ok code 0

There's an NPM bug for this exact problem. The bug has been "fixed" by Homebrew installing npm in a way that allows it to manage itself once the install is complete. However, this is error-prone and still seems to cause problems for some people. The root of the the issue is really that npm is its own package manager and it is therefore better to have npm manage itself and its packages completely on its own instead of letting Homebrew do it.

Also, using the Homebrew installation of npm will require you to use sudo when installing global packages. Since one of the core ideas behind Homebrew is that apps can be installed without giving them root access, this is a bad idea.

@dbaq

This comment has been minimized.

Show comment
Hide comment
@dbaq

dbaq Apr 17, 2014

Thanks! ๐Ÿ‘

dbaq commented Apr 17, 2014

Thanks! ๐Ÿ‘

@martypitt

This comment has been minimized.

Show comment
Hide comment
@martypitt

martypitt Apr 20, 2014

Outstanding! ๐Ÿ‘

martypitt commented Apr 20, 2014

Outstanding! ๐Ÿ‘

@semikolon

This comment has been minimized.

Show comment
Hide comment
@semikolon

semikolon Sep 19, 2014

I got these error messages, but it seems to have worked...

Fredriks-MacBook-Pro% curl -L https://www.npmjs.org/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6711 100 6711 0 0 8838 0 --:--:-- --:--:-- --:--:-- 8830
tar=/usr/bin/tar
version:
bsdtar 2.8.3 - libarchive 2.8.3
install npm@latest
fetching: http://registry.npmjs.org/npm/-/npm-2.0.0.tgz

/private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/bin/read-package-json.js:18
val = val[f]
^
TypeError: Cannot read property 'node' of undefined
at /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/bin/read-package-json.js:18:16
at Array.forEach (native)
at /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/bin/read-package-json.js:17:11
at Array.forEach (native)
at /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/bin/read-package-json.js:14:22
at /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/node_modules/read-package-json/read-json.js:51:40
at final (/private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/node_modules/read-package-json/read-json.js:349:17)
at then (/private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/node_modules/read-package-json/read-json.js:126:33)
at /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/node_modules/read-package-json/read-json.js:266:40
at evalmachine.:271:14
0.10.31

/private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/bin/read-package-json.js:18
val = val[f]
^
TypeError: Cannot read property 'node' of undefined
at /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/bin/read-package-json.js:18:16
at Array.forEach (native)
at /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/bin/read-package-json.js:17:11
at Array.forEach (native)
at /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/bin/read-package-json.js:14:22
at /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/node_modules/read-package-json/read-json.js:51:40
at final (/private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/node_modules/read-package-json/read-json.js:349:17)
at then (/private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/node_modules/read-package-json/read-json.js:126:33)
at /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/node_modules/read-package-json/read-json.js:266:40
at evalmachine.:271:14

npm@2.0.0 prepublish /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package
node bin/npm-cli.js prune --prefix=. --no-global && rm -rf test///node_modules && make -j8 doc

make: Nothing to be done for `doc'.
/Users/fredrikbranstrom/.node/bin/npm -> /Users/fredrikbranstrom/.node/lib/node_modules/npm/bin/npm-cli.js
npm@2.0.0 /Users/fredrikbranstrom/.node/lib/node_modules/npm
It worked
Fredriks-MacBook-Pro%

semikolon commented Sep 19, 2014

I got these error messages, but it seems to have worked...

Fredriks-MacBook-Pro% curl -L https://www.npmjs.org/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6711 100 6711 0 0 8838 0 --:--:-- --:--:-- --:--:-- 8830
tar=/usr/bin/tar
version:
bsdtar 2.8.3 - libarchive 2.8.3
install npm@latest
fetching: http://registry.npmjs.org/npm/-/npm-2.0.0.tgz

/private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/bin/read-package-json.js:18
val = val[f]
^
TypeError: Cannot read property 'node' of undefined
at /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/bin/read-package-json.js:18:16
at Array.forEach (native)
at /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/bin/read-package-json.js:17:11
at Array.forEach (native)
at /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/bin/read-package-json.js:14:22
at /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/node_modules/read-package-json/read-json.js:51:40
at final (/private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/node_modules/read-package-json/read-json.js:349:17)
at then (/private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/node_modules/read-package-json/read-json.js:126:33)
at /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/node_modules/read-package-json/read-json.js:266:40
at evalmachine.:271:14
0.10.31

/private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/bin/read-package-json.js:18
val = val[f]
^
TypeError: Cannot read property 'node' of undefined
at /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/bin/read-package-json.js:18:16
at Array.forEach (native)
at /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/bin/read-package-json.js:17:11
at Array.forEach (native)
at /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/bin/read-package-json.js:14:22
at /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/node_modules/read-package-json/read-json.js:51:40
at final (/private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/node_modules/read-package-json/read-json.js:349:17)
at then (/private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/node_modules/read-package-json/read-json.js:126:33)
at /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package/node_modules/read-package-json/read-json.js:266:40
at evalmachine.:271:14

npm@2.0.0 prepublish /private/var/folders/qs/8nmw36_11t727ckk5npwv81w0000gn/T/npm.29023/package
node bin/npm-cli.js prune --prefix=. --no-global && rm -rf test///node_modules && make -j8 doc

make: Nothing to be done for `doc'.
/Users/fredrikbranstrom/.node/bin/npm -> /Users/fredrikbranstrom/.node/lib/node_modules/npm/bin/npm-cli.js
npm@2.0.0 /Users/fredrikbranstrom/.node/lib/node_modules/npm
It worked
Fredriks-MacBook-Pro%

@SteveBenner

This comment has been minimized.

Show comment
Hide comment
@SteveBenner

SteveBenner Sep 23, 2014

This solution works for me, although it does make me sad that I canโ€™t use Homebrew. Iโ€™ve no idea whatโ€™s going on underneath the hood, as Iโ€™m primarily a Ruby guy. Two strange things jump out at me:

  1. Though ~/.node/bin is on my path, (and not being overridden) I cannot find any of the executables inside using the which -a commandโ€ฆ They nonetheless are fully functional.
  2. When I run npm update -g it appears to work as expected, but the following error message shows on completion:
npm ERR! Darwin 13.3.0
npm ERR! argv "node" "/Users/user/.node/bin/npm" "update" "-g"
npm ERR! node v0.10.32
npm ERR! npm  v2.0.0
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package npmconf does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer npm-registry-client@3.2.2 wants npmconf@^2.1.0

I surmised the problem may be npmconf, and perhaps itโ€™s related to this recently opened issue.

SteveBenner commented Sep 23, 2014

This solution works for me, although it does make me sad that I canโ€™t use Homebrew. Iโ€™ve no idea whatโ€™s going on underneath the hood, as Iโ€™m primarily a Ruby guy. Two strange things jump out at me:

  1. Though ~/.node/bin is on my path, (and not being overridden) I cannot find any of the executables inside using the which -a commandโ€ฆ They nonetheless are fully functional.
  2. When I run npm update -g it appears to work as expected, but the following error message shows on completion:
npm ERR! Darwin 13.3.0
npm ERR! argv "node" "/Users/user/.node/bin/npm" "update" "-g"
npm ERR! node v0.10.32
npm ERR! npm  v2.0.0
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package npmconf does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer npm-registry-client@3.2.2 wants npmconf@^2.1.0

I surmised the problem may be npmconf, and perhaps itโ€™s related to this recently opened issue.

@Martinspire

This comment has been minimized.

Show comment
Hide comment
@Martinspire

Martinspire Oct 1, 2014

Isn't it better to just uninstall node via homebrew and use the installer from nodejs.org? Separating them also seems a bit odd

Martinspire commented Oct 1, 2014

Isn't it better to just uninstall node via homebrew and use the installer from nodejs.org? Separating them also seems a bit odd

@paul-ylz

This comment has been minimized.

Show comment
Hide comment
@paul-ylz

paul-ylz Oct 12, 2014

Thanks this helped me fix my npm issues

paul-ylz commented Oct 12, 2014

Thanks this helped me fix my npm issues

@tomhanlon

This comment has been minimized.

Show comment
Hide comment
@tomhanlon

tomhanlon Oct 15, 2014

Huge help. Thanks.

tomhanlon commented Oct 15, 2014

Huge help. Thanks.

@captDaylight

This comment has been minimized.

Show comment
Hide comment
@captDaylight

captDaylight Oct 16, 2014

Wow, been looking for this solution for a full day. Thanks for posting, great stuff.

captDaylight commented Oct 16, 2014

Wow, been looking for this solution for a full day. Thanks for posting, great stuff.

@robbennet

This comment has been minimized.

Show comment
Hide comment
@robbennet

robbennet Oct 20, 2014

SO much this! Extremely helpful.

robbennet commented Oct 20, 2014

SO much this! Extremely helpful.

@tgrecojs

This comment has been minimized.

Show comment
Hide comment
@tgrecojs

tgrecojs Oct 24, 2014

Thank you!

tgrecojs commented Oct 24, 2014

Thank you!

@bingalls

This comment has been minimized.

Show comment
Hide comment
@bingalls

bingalls Oct 28, 2014

Please add this step, before deleting /usr/local/node_modules (to not lose all your work):
ls -1 /usr/local/node_modules > ~/node_modules.txt
at the end, do:
for i in cat ~/node_modules.txt;do npm install -g $i;done

Hopefully, it is not necessary to track module versions or the new private npm modules.

bingalls commented Oct 28, 2014

Please add this step, before deleting /usr/local/node_modules (to not lose all your work):
ls -1 /usr/local/node_modules > ~/node_modules.txt
at the end, do:
for i in cat ~/node_modules.txt;do npm install -g $i;done

Hopefully, it is not necessary to track module versions or the new private npm modules.

@espiler

This comment has been minimized.

Show comment
Hide comment
@espiler

espiler Nov 3, 2014

Thanks a ton!

espiler commented Nov 3, 2014

Thanks a ton!

@cmezian

This comment has been minimized.

Show comment
Hide comment
@cmezian

cmezian Nov 10, 2014

Worked like a charm for my older iMac, thank you!

cmezian commented Nov 10, 2014

Worked like a charm for my older iMac, thank you!

@GrimmOutlook

This comment has been minimized.

Show comment
Hide comment
@GrimmOutlook

GrimmOutlook Nov 16, 2014

Until I typed in "npm install -g blah, blah, blah", everything worked. Once I tried to re-install some global node modules, I get: "bash: /usr/local/bin/npm: No such file or directory". Anyone else run into this? Any thoughts? Seems like it can be fixed by something simple. Thanks!

GrimmOutlook commented Nov 16, 2014

Until I typed in "npm install -g blah, blah, blah", everything worked. Once I tried to re-install some global node modules, I get: "bash: /usr/local/bin/npm: No such file or directory". Anyone else run into this? Any thoughts? Seems like it can be fixed by something simple. Thanks!

@gavstah

This comment has been minimized.

Show comment
Hide comment
@gavstah

gavstah Nov 25, 2014

This worked a treat for me. Up until now, I'd been struggling to get node & npm going on my mac.

@GrimmOutlook - judging by the output, it seems like npm's looking in the wrong place - did you add ~/.npm/bin to your path and then run:

source ~/.bash_profile

to load the path change?

gavstah commented Nov 25, 2014

This worked a treat for me. Up until now, I'd been struggling to get node & npm going on my mac.

@GrimmOutlook - judging by the output, it seems like npm's looking in the wrong place - did you add ~/.npm/bin to your path and then run:

source ~/.bash_profile

to load the path change?

@pelachile

This comment has been minimized.

Show comment
Hide comment
@pelachile

pelachile Nov 28, 2014

Hmm. Now none of my newly installed global commands are found. In fact a node_modules folder isn't created in my home directory. All modules are being installed into /usr/local/bin/ which is already in my path.

pelachile commented Nov 28, 2014

Hmm. Now none of my newly installed global commands are found. In fact a node_modules folder isn't created in my home directory. All modules are being installed into /usr/local/bin/ which is already in my path.

@unostella

This comment has been minimized.

Show comment
Hide comment
@unostella

unostella Nov 30, 2014

Thanks for this, it all worked great up to the point when I re-open terminal, just like @GrimmOutlook described.
So after restarting terminal it says -bash: npm: command not found
So I have to export PATH="$HOME/.node/bin:$PATH" each time I open it up.
Any idea how to fix that?

unostella commented Nov 30, 2014

Thanks for this, it all worked great up to the point when I re-open terminal, just like @GrimmOutlook described.
So after restarting terminal it says -bash: npm: command not found
So I have to export PATH="$HOME/.node/bin:$PATH" each time I open it up.
Any idea how to fix that?

@merraysy

This comment has been minimized.

Show comment
Hide comment
@merraysy

merraysy Dec 15, 2014

thanks your are the ๐Ÿ‘จ

merraysy commented Dec 15, 2014

thanks your are the ๐Ÿ‘จ

@brockthebear

This comment has been minimized.

Show comment
Hide comment
@brockthebear

brockthebear Dec 24, 2014

Incredibly helpful. Thanks so much.

brockthebear commented Dec 24, 2014

Incredibly helpful. Thanks so much.

@aljopro

This comment has been minimized.

Show comment
Hide comment
@aljopro

aljopro Dec 28, 2014

@unostella, I had to put the export ~/.profile instead of ~/.path

aljopro commented Dec 28, 2014

@unostella, I had to put the export ~/.profile instead of ~/.path

@johannyberg

This comment has been minimized.

Show comment
Hide comment
@johannyberg

johannyberg commented Dec 31, 2014

Thank you!

@kaishin

This comment has been minimized.

Show comment
Hide comment
@kaishin

kaishin Dec 31, 2014

This worked great, thanks!

kaishin commented Dec 31, 2014

This worked great, thanks!

@watsy0007

This comment has been minimized.

Show comment
Hide comment
@watsy0007

watsy0007 Jan 3, 2015

thank you!

watsy0007 commented Jan 3, 2015

thank you!

@chenrui333

This comment has been minimized.

Show comment
Hide comment
@chenrui333

chenrui333 Jan 4, 2015

node 0.10.26 is still installed.
Remove them all with brew uninstall --force node.

chenrui333 commented Jan 4, 2015

node 0.10.26 is still installed.
Remove them all with brew uninstall --force node.

@chenrui333

This comment has been minimized.

Show comment
Hide comment
@chenrui333

chenrui333 Jan 4, 2015

Also, "npm cache clear" is good for testing the cmd as well.

Thanks for the gist!

chenrui333 commented Jan 4, 2015

Also, "npm cache clear" is good for testing the cmd as well.

Thanks for the gist!

@phudekar

This comment has been minimized.

Show comment
Hide comment
@phudekar

phudekar Jan 6, 2015

Thanks. You saved my day

phudekar commented Jan 6, 2015

Thanks. You saved my day

@morganloehr

This comment has been minimized.

Show comment
Hide comment
@morganloehr

morganloehr Jan 9, 2015

Serious thanks for this!

morganloehr commented Jan 9, 2015

Serious thanks for this!

@favorit

This comment has been minimized.

Show comment
Hide comment
@favorit

favorit Jan 20, 2015

Thank you! It works for me!

favorit commented Jan 20, 2015

Thank you! It works for me!

@philbritton

This comment has been minimized.

Show comment
Hide comment
@philbritton

philbritton Jan 20, 2015

awesome, i'm back in business, thanks!

philbritton commented Jan 20, 2015

awesome, i'm back in business, thanks!

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Jan 24, 2015

Thankyou so much!

ghost commented Jan 24, 2015

Thankyou so much!

@dan-mckay

This comment has been minimized.

Show comment
Hide comment
@dan-mckay

dan-mckay Jan 26, 2015

More thanks from me, too ;)

dan-mckay commented Jan 26, 2015

More thanks from me, too ;)

@joshuakemp1

This comment has been minimized.

Show comment
Hide comment
@joshuakemp1

joshuakemp1 commented Jan 27, 2015

THANKS!!

@prokizzle

This comment has been minimized.

Show comment
Hide comment
@prokizzle

prokizzle Feb 2, 2015

Thank you so very much!

prokizzle commented Feb 2, 2015

Thank you so very much!

@fa3

This comment has been minimized.

Show comment
Hide comment
@fa3

fa3 Feb 3, 2015

What can i say instead Thank you? Ha, thank you very much!

fa3 commented Feb 3, 2015

What can i say instead Thank you? Ha, thank you very much!

@NandoSantana

This comment has been minimized.

Show comment
Hide comment
@NandoSantana

NandoSantana Feb 8, 2015

hi, printed error: /usr/local/bin/npm: No such file or directory , help me.

NandoSantana commented Feb 8, 2015

hi, printed error: /usr/local/bin/npm: No such file or directory , help me.

@pedrocatre

This comment has been minimized.

Show comment
Hide comment
@pedrocatre

pedrocatre Feb 9, 2015

Thank you so much!

pedrocatre commented Feb 9, 2015

Thank you so much!

@guimap

This comment has been minimized.

Show comment
Hide comment
@guimap

guimap Feb 11, 2015

Thanksss man, u save my life, thanks thanks....

guimap commented Feb 11, 2015

Thanksss man, u save my life, thanks thanks....

@thechrisproject

This comment has been minimized.

Show comment
Hide comment
@thechrisproject

thechrisproject Feb 13, 2015

Dang, I tried these instructions and everything worked well until running the script:

$ curl -L https://www.npmjs.org/install.sh | sh % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 51 100 51 0 0 124 0 --:--:-- --:--:-- --:--:-- 124 100 6239 100 6239 0 0 8293 0 --:--:-- --:--:-- --:--:-- 23022 sh: line 21: npm-install-36841.sh: Permission denied rm: npm-install-36841.sh: No such file or directory Failed to download script

thechrisproject commented Feb 13, 2015

Dang, I tried these instructions and everything worked well until running the script:

$ curl -L https://www.npmjs.org/install.sh | sh % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 51 100 51 0 0 124 0 --:--:-- --:--:-- --:--:-- 124 100 6239 100 6239 0 0 8293 0 --:--:-- --:--:-- --:--:-- 23022 sh: line 21: npm-install-36841.sh: Permission denied rm: npm-install-36841.sh: No such file or directory Failed to download script

@mnlsn

This comment has been minimized.

Show comment
Hide comment
@mnlsn

mnlsn Feb 15, 2015

use curl -L https://www.npmjs.com/install.sh | sh if you get the Permission Denied error when installing npm

mnlsn commented Feb 15, 2015

use curl -L https://www.npmjs.com/install.sh | sh if you get the Permission Denied error when installing npm

@rowild

This comment has been minimized.

Show comment
Hide comment
@rowild

rowild Feb 19, 2015

I got an error on Mac Maverick 10.9.5, because I use MAMP, which elivers its own libtool. I could solve this problem by creating a symlink from the MAMP version to the bin version

// create backup of MAMP libtool
mv /Applications/MAMP/bin/libtool /Applications/MAMP/bin/libtool_orig

// create symlink
ln -s /usr/bin/libtool /Applications/MAMP/bin/libtool

// then install node

Just in case somebody got the same error...

Thanks for your solution!!!

rowild commented Feb 19, 2015

I got an error on Mac Maverick 10.9.5, because I use MAMP, which elivers its own libtool. I could solve this problem by creating a symlink from the MAMP version to the bin version

// create backup of MAMP libtool
mv /Applications/MAMP/bin/libtool /Applications/MAMP/bin/libtool_orig

// create symlink
ln -s /usr/bin/libtool /Applications/MAMP/bin/libtool

// then install node

Just in case somebody got the same error...

Thanks for your solution!!!

@yonatann

This comment has been minimized.

Show comment
Hide comment
@yonatann

yonatann Feb 20, 2015

Worked like a charm!

yonatann commented Feb 20, 2015

Worked like a charm!

@jinyoungc

This comment has been minimized.

Show comment
Hide comment
@jinyoungc

jinyoungc Feb 21, 2015

OMG THANK YOU!!!!!!

jinyoungc commented Feb 21, 2015

OMG THANK YOU!!!!!!

@jserrao

This comment has been minimized.

Show comment
Hide comment
@jserrao

jserrao Feb 23, 2015

FYI: 'curl -L https://www.npmjs.org/install.sh | sh' returns a 404 for me. Just drop the https to http and things worked swimmingly. Thanks for digging into this issue. I've long had conflicts similar to those noted in your post and this resolved a great many of them.

jserrao commented Feb 23, 2015

FYI: 'curl -L https://www.npmjs.org/install.sh | sh' returns a 404 for me. Just drop the https to http and things worked swimmingly. Thanks for digging into this issue. I've long had conflicts similar to those noted in your post and this resolved a great many of them.

@irealva

This comment has been minimized.

Show comment
Hide comment
@irealva

irealva Feb 24, 2015

Awesome, this helped a lot. I first ran:

$ brew doctor

and fixed all the node related warning. Then followed your instructions and it worked like a charm.

This page helped too: http://forums.webhook.com/t/cant-get-node-to-install-on-latest-osx-mavericks-resolved/109/5

irealva commented Feb 24, 2015

Awesome, this helped a lot. I first ran:

$ brew doctor

and fixed all the node related warning. Then followed your instructions and it worked like a charm.

This page helped too: http://forums.webhook.com/t/cant-get-node-to-install-on-latest-osx-mavericks-resolved/109/5

@reesejohn69

This comment has been minimized.

Show comment
Hide comment
@reesejohn69

reesejohn69 Mar 10, 2015

If I use brew install node --without-npm command to isntall node, what's gonna happen when node gets updated via homebrew? Will that install npm?

reesejohn69 commented Mar 10, 2015

If I use brew install node --without-npm command to isntall node, what's gonna happen when node gets updated via homebrew? Will that install npm?

@benpolinsky

This comment has been minimized.

Show comment
Hide comment
@benpolinsky

benpolinsky Mar 10, 2015

Thanks so much.

benpolinsky commented Mar 10, 2015

Thanks so much.

@dnlserrano

This comment has been minimized.

Show comment
Hide comment
@dnlserrano

dnlserrano Mar 13, 2015

Thanks! You're the man! ๐Ÿ‘‘

dnlserrano commented Mar 13, 2015

Thanks! You're the man! ๐Ÿ‘‘

@rebekahkwon

This comment has been minimized.

Show comment
Hide comment
@rebekahkwon

rebekahkwon Mar 13, 2015

๐Ÿ‘ thank you!

rebekahkwon commented Mar 13, 2015

๐Ÿ‘ thank you!

@reiaguilera

This comment has been minimized.

Show comment
Hide comment
@reiaguilera

reiaguilera Mar 19, 2015

Excelent ! (Y)

reiaguilera commented Mar 19, 2015

Excelent ! (Y)

@guoylyy

This comment has been minimized.

Show comment
Hide comment
@guoylyy

guoylyy Mar 27, 2015

Excelent! Thanks a lot.

guoylyy commented Mar 27, 2015

Excelent! Thanks a lot.

@mikeymco

This comment has been minimized.

Show comment
Hide comment
@mikeymco

mikeymco Mar 27, 2015

Thanks ๐Ÿ‘

mikeymco commented Mar 27, 2015

Thanks ๐Ÿ‘

@jklegseth

This comment has been minimized.

Show comment
Hide comment
@jklegseth

jklegseth Apr 4, 2015

Thanks! Nothing's ever easy...

jklegseth commented Apr 4, 2015

Thanks! Nothing's ever easy...

@mitogh

This comment has been minimized.

Show comment
Hide comment
@mitogh

mitogh Apr 5, 2015

Thanks, works perfect. ๐Ÿ‘

mitogh commented Apr 5, 2015

Thanks, works perfect. ๐Ÿ‘

@arnelh

This comment has been minimized.

Show comment
Hide comment
@arnelh

arnelh commented Apr 15, 2015

Thanks

@codykrainock

This comment has been minimized.

Show comment
Hide comment
@codykrainock

codykrainock commented Apr 19, 2015

Thank you!

@JonMasterson

This comment has been minimized.

Show comment
Hide comment
@JonMasterson

JonMasterson Apr 19, 2015

Thanks so much!

JonMasterson commented Apr 19, 2015

Thanks so much!

@thedamon

This comment has been minimized.

Show comment
Hide comment
@thedamon

thedamon Apr 19, 2015

Awesome to see this! But it's weird. I followed the instructions and added .npm and .node\bin to my zshrc, but I am still getting the access errors. Sumfin not quite right

thedamon commented Apr 19, 2015

Awesome to see this! But it's weird. I followed the instructions and added .npm and .node\bin to my zshrc, but I am still getting the access errors. Sumfin not quite right

@mariarivas

This comment has been minimized.

Show comment
Hide comment
@mariarivas

mariarivas Apr 20, 2015

Awesome, thanks!

mariarivas commented Apr 20, 2015

Awesome, thanks!

@zekitow

This comment has been minimized.

Show comment
Hide comment
@zekitow

zekitow Apr 24, 2015

Thanks!!!

Cheeers!

zekitow commented Apr 24, 2015

Thanks!!!

Cheeers!

@buk

This comment has been minimized.

Show comment
Hide comment
@buk

buk Apr 27, 2015

Thanks!

buk commented Apr 27, 2015

Thanks!

@limichange

This comment has been minimized.

Show comment
Hide comment
@limichange

limichange Apr 30, 2015

ThanksO(โˆฉ_โˆฉ)O๏ผ

limichange commented Apr 30, 2015

ThanksO(โˆฉ_โˆฉ)O๏ผ

@alphapilgrim

This comment has been minimized.

Show comment
Hide comment
@alphapilgrim

alphapilgrim commented May 2, 2015

Thanks!!

@SGD1953

This comment has been minimized.

Show comment
Hide comment
@SGD1953

SGD1953 May 5, 2015

Thanks a lot, I got errors when installing npm, doing an additional sudo rm -rf ~/.npm did the trick for me.

SGD1953 commented May 5, 2015

Thanks a lot, I got errors when installing npm, doing an additional sudo rm -rf ~/.npm did the trick for me.

@dillorscroft

This comment has been minimized.

Show comment
Hide comment
@dillorscroft

dillorscroft May 8, 2015

I get a strange warning/error but then it proceeds to say "It worked"

curl -L https://www.npmjs.com/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6239 100 6239 0 0 6043 0 0:00:01 0:00:01 --:--:-- 6045
tar=/usr/bin/tar
version:
bsdtar 2.8.3 - libarchive 2.8.3
install npm@latest
fetching: http://registry.npmjs.org/npm/-/npm-2.9.1.tgz

npm@2.9.1 prepublish /private/var/folders/1m/f2btkb_j5ng6bzhmzmm73hc40000gn/T/npm.32190/package
node bin/npm-cli.js prune --prefix=. --no-global && rimraf test///node_modules && make -j4 doc

sh: rimraf: command not found

dillorscroft commented May 8, 2015

I get a strange warning/error but then it proceeds to say "It worked"

curl -L https://www.npmjs.com/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6239 100 6239 0 0 6043 0 0:00:01 0:00:01 --:--:-- 6045
tar=/usr/bin/tar
version:
bsdtar 2.8.3 - libarchive 2.8.3
install npm@latest
fetching: http://registry.npmjs.org/npm/-/npm-2.9.1.tgz

npm@2.9.1 prepublish /private/var/folders/1m/f2btkb_j5ng6bzhmzmm73hc40000gn/T/npm.32190/package
node bin/npm-cli.js prune --prefix=. --no-global && rimraf test///node_modules && make -j4 doc

sh: rimraf: command not found

@k7n4n5t3w4rt

This comment has been minimized.

Show comment
Hide comment
@k7n4n5t3w4rt

k7n4n5t3w4rt May 10, 2015

Many thanks. Installing npm with Homebrew never seemed to work properly but I never knew why. Now I still don't but have them installed :)

I had to use SGD1953's tip and do "sudo rm -rf ~/.npm" before installing npm. Otherwise this happened.

npm ERR! Darwin 13.4.0
npm ERR! argv "/usr/local/bin/node" "/private/var/folders/_b/g8fdbnmx317_s0dlnp784pbr0000gn/T/npm.33170/package/cli.js" "install" "-gf"
npm ERR! node v0.12.2
npm ERR! npm v2.9.1

npm ERR! Attempt to unlock /Users/[MYUSER]/.node/lib/node_modules/npm, which hasn't been locked

k7n4n5t3w4rt commented May 10, 2015

Many thanks. Installing npm with Homebrew never seemed to work properly but I never knew why. Now I still don't but have them installed :)

I had to use SGD1953's tip and do "sudo rm -rf ~/.npm" before installing npm. Otherwise this happened.

npm ERR! Darwin 13.4.0
npm ERR! argv "/usr/local/bin/node" "/private/var/folders/_b/g8fdbnmx317_s0dlnp784pbr0000gn/T/npm.33170/package/cli.js" "install" "-gf"
npm ERR! node v0.12.2
npm ERR! npm v2.9.1

npm ERR! Attempt to unlock /Users/[MYUSER]/.node/lib/node_modules/npm, which hasn't been locked

@jovincroninwilesmith

This comment has been minimized.

Show comment
Hide comment
@jovincroninwilesmith

jovincroninwilesmith May 10, 2015

@unostella did you ever figure out a fix? I am still getting the same error.

jovincroninwilesmith commented May 10, 2015

@unostella did you ever figure out a fix? I am still getting the same error.

@sebklaus

This comment has been minimized.

Show comment
Hide comment
@sebklaus

sebklaus May 13, 2015

Thank you very much! Works a treat!

sebklaus commented May 13, 2015

Thank you very much! Works a treat!

@azonirunner

This comment has been minimized.

Show comment
Hide comment
@azonirunner

azonirunner May 13, 2015

Thank you. Works! Had to add the sudo rm -rf ~/.npm (tip from SGD1953)

azonirunner commented May 13, 2015

Thank you. Works! Had to add the sudo rm -rf ~/.npm (tip from SGD1953)

@sudostack

This comment has been minimized.

Show comment
Hide comment
@sudostack

sudostack May 14, 2015

wow! thanks! resolved a totally different error message for me, but awesome! kudos!

sudostack commented May 14, 2015

wow! thanks! resolved a totally different error message for me, but awesome! kudos!

@deepakmani

This comment has been minimized.

Show comment
Hide comment
@deepakmani

deepakmani May 15, 2015

This was very useful when I had to re-install npm .

deepakmani commented May 15, 2015

This was very useful when I had to re-install npm .

@iainwatt

This comment has been minimized.

Show comment
Hide comment
@iainwatt

iainwatt commented May 18, 2015

Ledge!

@0is1

This comment has been minimized.

Show comment
Hide comment
@0is1

0is1 May 18, 2015

Yes, thanks! This was really helpful :)

0is1 commented May 18, 2015

Yes, thanks! This was really helpful :)

@aidansmyth

This comment has been minimized.

Show comment
Hide comment
@aidansmyth

aidansmyth May 22, 2015

Worked great except for one issue, after running brew install node --without-npm i kept getting
"Could not symlink lib/dtrace/node.d
/usr/local/lib/dtrace is not writable"

I had to run 'sudo chown -R whoami /usr/local' to be able to link brew to node.

aidansmyth commented May 22, 2015

Worked great except for one issue, after running brew install node --without-npm i kept getting
"Could not symlink lib/dtrace/node.d
/usr/local/lib/dtrace is not writable"

I had to run 'sudo chown -R whoami /usr/local' to be able to link brew to node.

@anthonybrown

This comment has been minimized.

Show comment
Hide comment
@anthonybrown

anthonybrown May 24, 2015

This is funny, I came about the same solution through trial and error and stack overflow.

anthonybrown commented May 24, 2015

This is funny, I came about the same solution through trial and error and stack overflow.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost May 28, 2015

Thank you!!!

ghost commented May 28, 2015

Thank you!!!

@ser111

This comment has been minimized.

Show comment
Hide comment
@ser111

ser111 May 30, 2015

You're the man.

ser111 commented May 30, 2015

You're the man.

@jonrh

This comment has been minimized.

Show comment
Hide comment
@jonrh

jonrh Jun 7, 2015

Awesome, thank you! Following the instructions I ran into some Homebrew issues. Running brew update and then following the instructions again worked.

jonrh commented Jun 7, 2015

Awesome, thank you! Following the instructions I ran into some Homebrew issues. Running brew update and then following the instructions again worked.

@sagic

This comment has been minimized.

Show comment
Hide comment
@sagic

sagic Jun 8, 2015

thanks :)

sagic commented Jun 8, 2015

thanks :)

@adaam2

This comment has been minimized.

Show comment
Hide comment
@adaam2

adaam2 Jun 12, 2015

This is awesome! great work

adaam2 commented Jun 12, 2015

This is awesome! great work

@jromeem

This comment has been minimized.

Show comment
Hide comment
@jromeem

jromeem Jun 14, 2015

this is great!! thanks a butt ton! ๐Ÿ‘

jromeem commented Jun 14, 2015

this is great!! thanks a butt ton! ๐Ÿ‘

@bghill

This comment has been minimized.

Show comment
Hide comment
@bghill

bghill Jun 15, 2015

At some point I must have installed node.js directly. Later I installed via brew. I suspect this is what led my version of node get screwed up file permissions. Out of curiosity, I wanted to see if a "clean" install of node from homebrew would still have the permissions issue. I followed this script: https://gist.github.com/nicerobot/2697848 for most of the uninstall. I also had to remove the ~/.npm and /usr/local/share/systemtap. I only removed the latter after verifying that there was nothing in it related to anything else on my system. With that done, I was able to execute brew install node and the permission issues seem to have disappeared. npm update npm -g now works fine, as does the build process that was giving me trouble.

Let me know if this works for anyone else. I'm curious if most folks just have a long forgotten collision between installs, and complete cleanup is the current solution.

bghill commented Jun 15, 2015

At some point I must have installed node.js directly. Later I installed via brew. I suspect this is what led my version of node get screwed up file permissions. Out of curiosity, I wanted to see if a "clean" install of node from homebrew would still have the permissions issue. I followed this script: https://gist.github.com/nicerobot/2697848 for most of the uninstall. I also had to remove the ~/.npm and /usr/local/share/systemtap. I only removed the latter after verifying that there was nothing in it related to anything else on my system. With that done, I was able to execute brew install node and the permission issues seem to have disappeared. npm update npm -g now works fine, as does the build process that was giving me trouble.

Let me know if this works for anyone else. I'm curious if most folks just have a long forgotten collision between installs, and complete cleanup is the current solution.

@apzentral

This comment has been minimized.

Show comment
Hide comment
@apzentral

apzentral Jun 18, 2015

This is awesome. Thank you.

apzentral commented Jun 18, 2015

This is awesome. Thank you.

@BenLittle

This comment has been minimized.

Show comment
Hide comment
@BenLittle

BenLittle Jun 19, 2015

Excellent. Thank you!

BenLittle commented Jun 19, 2015

Excellent. Thank you!

@dcondrey

This comment has been minimized.

Show comment
Hide comment
@dcondrey

dcondrey Jun 22, 2015


git clone git://github.com/ry/node.git
(cd node && ./configure && make && sudo make install)
chown -R "$USER" /usr/local/{share/man,bin,lib/node,include/node};
npm update npm -g
node -v && npm -v

dcondrey commented Jun 22, 2015


git clone git://github.com/ry/node.git
(cd node && ./configure && make && sudo make install)
chown -R "$USER" /usr/local/{share/man,bin,lib/node,include/node};
npm update npm -g
node -v && npm -v
@JoeDuncko

This comment has been minimized.

Show comment
Hide comment
@JoeDuncko

JoeDuncko commented Jun 30, 2015

Thanks!

@gbanis

This comment has been minimized.

Show comment
Hide comment
@gbanis

gbanis Jul 1, 2015

Worked like a charm. Later I had to remove nvm as well and now everything is in tune. Thank you!

gbanis commented Jul 1, 2015

Worked like a charm. Later I had to remove nvm as well and now everything is in tune. Thank you!

@aking13

This comment has been minimized.

Show comment
Hide comment
@aking13

aking13 Jul 2, 2015

You have literally brought so much satisfaction to 3 hours of troubleshooting with so many nodejs, npm, brew problems. Thank you! Thank you!

aking13 commented Jul 2, 2015

You have literally brought so much satisfaction to 3 hours of troubleshooting with so many nodejs, npm, brew problems. Thank you! Thank you!

@dannguyen

This comment has been minimized.

Show comment
Hide comment
@dannguyen

dannguyen Jul 4, 2015

The installation process works for me (i.e. it doesn't break) but after installing packages globally, I find that node apparently won't look at the default global path for npm packages. Installing packages locally works just fine.

dannguyen commented Jul 4, 2015

The installation process works for me (i.e. it doesn't break) but after installing packages globally, I find that node apparently won't look at the default global path for npm packages. Installing packages locally works just fine.

@parsafatehi

This comment has been minimized.

Show comment
Hide comment
@parsafatehi

parsafatehi Jul 10, 2015

Thanks, It worked ๐Ÿ˜Š

parsafatehi commented Jul 10, 2015

Thanks, It worked ๐Ÿ˜Š

@RoySegall

This comment has been minimized.

Show comment
Hide comment
@RoySegall

RoySegall Jul 11, 2015

Working like a glove!

RoySegall commented Jul 11, 2015

Working like a glove!

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Jul 13, 2015

Fantastic solution - it sorted my problem with installing react native :) Many thanks

ghost commented Jul 13, 2015

Fantastic solution - it sorted my problem with installing react native :) Many thanks

@chitopolo

This comment has been minimized.

Show comment
Hide comment
@chitopolo

chitopolo Jul 14, 2015

Thank you very much, it worked! ;)

chitopolo commented Jul 14, 2015

Thank you very much, it worked! ;)

@gabrielribeiro

This comment has been minimized.

Show comment
Hide comment
@gabrielribeiro

gabrielribeiro Jul 16, 2015

Didn't work for me

Got the following error:

-bash: npm: command not found

My .bash_profile:

[[ -s ~/.bashrc ]] && source ~/.bashrc

My .bashrc:

source dnvm.sh
export MONO_MANAGED_WATCHER=disabled

My .path:

export PATH=/Users/GabrielRibeiro/.node/bin:/Users/GabrielRibeiro/.dnx/runtimes/dnx-mono.1.0.0-b$
export PATH="$HOME/.node/bin:$PATH"

What I did wrong?

gabrielribeiro commented Jul 16, 2015

Didn't work for me

Got the following error:

-bash: npm: command not found

My .bash_profile:

[[ -s ~/.bashrc ]] && source ~/.bashrc

My .bashrc:

source dnvm.sh
export MONO_MANAGED_WATCHER=disabled

My .path:

export PATH=/Users/GabrielRibeiro/.node/bin:/Users/GabrielRibeiro/.dnx/runtimes/dnx-mono.1.0.0-b$
export PATH="$HOME/.node/bin:$PATH"

What I did wrong?

@qqilihq

This comment has been minimized.

Show comment
Hide comment
@qqilihq

qqilihq Jul 24, 2015

Worked like a charm. Thank you!

qqilihq commented Jul 24, 2015

Worked like a charm. Thank you!

@philals

This comment has been minimized.

Show comment
Hide comment
@philals

philals commented Jul 26, 2015

Thanks!

@ljhan

This comment has been minimized.

Show comment
Hide comment
@ljhan

ljhan Aug 2, 2015

Thank you so much for the help! I still have to export PATH="$HOME/.node/bin:$PATH" each time terminal is re-opened... Could there be a problem with the NODE_PATH?

ljhan commented Aug 2, 2015

Thank you so much for the help! I still have to export PATH="$HOME/.node/bin:$PATH" each time terminal is re-opened... Could there be a problem with the NODE_PATH?

@agostlg

This comment has been minimized.

Show comment
Hide comment
@agostlg

agostlg commented Aug 2, 2015

Thanks!

@WeHateNick

This comment has been minimized.

Show comment
Hide comment
@WeHateNick

WeHateNick Aug 5, 2015

I was able to install node without npm through brew but I get this error when running the curl command:

nick$ curl -L https://www.npmjs.com/install.sh | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  6239  100  6239    0     0   8375      0 --:--:-- --:--:-- --:--:--  8374
tar=/usr/bin/tar
version:
bsdtar 2.8.3 - libarchive 2.8.3
install npm@latest
fetching: http://registry.npmjs.org/npm/-/npm-2.13.3.tgz
npm ERR! Darwin 14.3.0
npm ERR! argv "/usr/local/bin/node" "/private/var/folders/hq/2mf0j5sj0c160gl3x33btbmr0000gn/T/npm.4470/package/cli.js" "rm" "npm" "-gf"
npm ERR! node v0.12.7
npm ERR! npm  v2.13.3
npm ERR! path /Users/nick/.node/lib/node_modules/npm/node_modules
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, rmdir '/Users/nick/.node/lib/node_modules/npm/node_modules'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, rmdir '/Users/nick/.node/lib/node_modules/npm/node_modules']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/Users/nick/.node/lib/node_modules/npm/node_modules' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /private/var/folders/hq/2mf0j5sj0c160gl3x33btbmr0000gn/T/npm.4470/package/npm-debug.log

> npm@2.13.3 prepublish /private/var/folders/hq/2mf0j5sj0c160gl3x33btbmr0000gn/T/npm.4470/package
> node bin/npm-cli.js prune --prefix=. --no-global && rimraf test/*/*/node_modules && make -j4 doc

sh: rimraf: command not found
npm ERR! Darwin 14.3.0
npm ERR! argv "/usr/local/bin/node" "/private/var/folders/hq/2mf0j5sj0c160gl3x33btbmr0000gn/T/npm.4470/package/cli.js" "install" "-gf"
npm ERR! node v0.12.7
npm ERR! npm  v2.13.3
npm ERR! path /Users/nick/.node/lib/node_modules/npm/node_modules
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, rmdir '/Users/nick/.node/lib/node_modules/npm/node_modules'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, rmdir '/Users/nick/.node/lib/node_modules/npm/node_modules']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/Users/nick/.node/lib/node_modules/npm/node_modules' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
npm ERR! error rolling back Error: EACCES, rmdir '/Users/nick/.node/lib/node_modules/npm/node_modules'
npm ERR! error rolling back     at Error (native)
npm ERR! error rolling back  { [Error: EACCES, rmdir '/Users/nick/.node/lib/node_modules/npm/node_modules']
npm ERR! error rolling back   errno: -13,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/Users/nick/.node/lib/node_modules/npm/node_modules' }

npm ERR! Please include the following file with any support request:
npm ERR!     /private/var/folders/hq/2mf0j5sj0c160gl3x33btbmr0000gn/T/npm.4470/package/npm-debug.log
It failed

Any ideas?

WeHateNick commented Aug 5, 2015

I was able to install node without npm through brew but I get this error when running the curl command:

nick$ curl -L https://www.npmjs.com/install.sh | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  6239  100  6239    0     0   8375      0 --:--:-- --:--:-- --:--:--  8374
tar=/usr/bin/tar
version:
bsdtar 2.8.3 - libarchive 2.8.3
install npm@latest
fetching: http://registry.npmjs.org/npm/-/npm-2.13.3.tgz
npm ERR! Darwin 14.3.0
npm ERR! argv "/usr/local/bin/node" "/private/var/folders/hq/2mf0j5sj0c160gl3x33btbmr0000gn/T/npm.4470/package/cli.js" "rm" "npm" "-gf"
npm ERR! node v0.12.7
npm ERR! npm  v2.13.3
npm ERR! path /Users/nick/.node/lib/node_modules/npm/node_modules
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, rmdir '/Users/nick/.node/lib/node_modules/npm/node_modules'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, rmdir '/Users/nick/.node/lib/node_modules/npm/node_modules']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/Users/nick/.node/lib/node_modules/npm/node_modules' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /private/var/folders/hq/2mf0j5sj0c160gl3x33btbmr0000gn/T/npm.4470/package/npm-debug.log

> npm@2.13.3 prepublish /private/var/folders/hq/2mf0j5sj0c160gl3x33btbmr0000gn/T/npm.4470/package
> node bin/npm-cli.js prune --prefix=. --no-global && rimraf test/*/*/node_modules && make -j4 doc

sh: rimraf: command not found
npm ERR! Darwin 14.3.0
npm ERR! argv "/usr/local/bin/node" "/private/var/folders/hq/2mf0j5sj0c160gl3x33btbmr0000gn/T/npm.4470/package/cli.js" "install" "-gf"
npm ERR! node v0.12.7
npm ERR! npm  v2.13.3
npm ERR! path /Users/nick/.node/lib/node_modules/npm/node_modules
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, rmdir '/Users/nick/.node/lib/node_modules/npm/node_modules'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, rmdir '/Users/nick/.node/lib/node_modules/npm/node_modules']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/Users/nick/.node/lib/node_modules/npm/node_modules' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
npm ERR! error rolling back Error: EACCES, rmdir '/Users/nick/.node/lib/node_modules/npm/node_modules'
npm ERR! error rolling back     at Error (native)
npm ERR! error rolling back  { [Error: EACCES, rmdir '/Users/nick/.node/lib/node_modules/npm/node_modules']
npm ERR! error rolling back   errno: -13,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   path: '/Users/nick/.node/lib/node_modules/npm/node_modules' }

npm ERR! Please include the following file with any support request:
npm ERR!     /private/var/folders/hq/2mf0j5sj0c160gl3x33btbmr0000gn/T/npm.4470/package/npm-debug.log
It failed

Any ideas?

@aliwatters

This comment has been minimized.

Show comment
Hide comment
@aliwatters

aliwatters Aug 5, 2015

@WeHateNick try $ curl -L https://www.npmjs.com/install.sh | sudo sh

aliwatters commented Aug 5, 2015

@WeHateNick try $ curl -L https://www.npmjs.com/install.sh | sudo sh

@walterspieler

This comment has been minimized.

Show comment
Hide comment
@walterspieler

walterspieler Aug 7, 2015

@ljhan I had the same as you have.
I solved the problem by doing this :
$ touch .bash_profile
$ open .bash_profile
In .bash_profil i added this line
source ~/.bashrc

http://hathaway.cc/post/69201163472/how-to-edit-your-path-environment-variables-on-mac

walterspieler commented Aug 7, 2015

@ljhan I had the same as you have.
I solved the problem by doing this :
$ touch .bash_profile
$ open .bash_profile
In .bash_profil i added this line
source ~/.bashrc

http://hathaway.cc/post/69201163472/how-to-edit-your-path-environment-variables-on-mac

@Adomeister

This comment has been minimized.

Show comment
Hide comment
@Adomeister

Adomeister Aug 12, 2015

THANKYOU @aliwatters this has been bugging me for days!

Adomeister commented Aug 12, 2015

THANKYOU @aliwatters this has been bugging me for days!

@grantpowell

This comment has been minimized.

Show comment
Hide comment
@grantpowell

grantpowell Aug 17, 2015

Cannot install, get error: "npm-install-34536.sh: Permission denied" when attempting "curl -L https://www.npmjs.com/install.sh | sh"

grantpowell commented Aug 17, 2015

Cannot install, get error: "npm-install-34536.sh: Permission denied" when attempting "curl -L https://www.npmjs.com/install.sh | sh"

@ccheatham

This comment has been minimized.

Show comment
Hide comment
@ccheatham

ccheatham Aug 22, 2015

In accordance with what @walterspieler said above if you continue to see this error after you add the source ~/.bashrc it could be because you already have a .node directory in your home directory. I renamed my current .node directory (you could just delete it) then ran it again and it worked. Also you may already have a .profile in which case you can add the source ~/.bashrc to it instead.

ccheatham commented Aug 22, 2015

In accordance with what @walterspieler said above if you continue to see this error after you add the source ~/.bashrc it could be because you already have a .node directory in your home directory. I renamed my current .node directory (you could just delete it) then ran it again and it worked. Also you may already have a .profile in which case you can add the source ~/.bashrc to it instead.

@alexortiz201

This comment has been minimized.

Show comment
Hide comment
@alexortiz201

alexortiz201 Aug 23, 2015

@ljhan you have to add export PATH="$HOME/.node/bin:$PATH" to your ~/.bash_profile or ~/.path file

alexortiz201 commented Aug 23, 2015

@ljhan you have to add export PATH="$HOME/.node/bin:$PATH" to your ~/.bash_profile or ~/.path file

@mitchstewart08

This comment has been minimized.

Show comment
Hide comment
@mitchstewart08

mitchstewart08 commented Aug 24, 2015

Thanks a lot!

@jitendravyas

This comment has been minimized.

Show comment
Hide comment
@jitendravyas

jitendravyas Aug 26, 2015

@alexortiz201 - I use zsh and ohmyzsh. how to make it work for me

jitendravyas commented Aug 26, 2015

@alexortiz201 - I use zsh and ohmyzsh. how to make it work for me

@mmizutani

This comment has been minimized.

Show comment
Hide comment
@mmizutani

mmizutani Aug 30, 2015

In a nutshell:

ls -1 /usr/local/lib/node_modules > ~/node_modules.txt
sed -e "s,/\+$,," -e "s,^/\+,," ~/node_modules.txt
rm -rf /usr/local/lib/node_modules
brew uninstall node --force node
brew install node --without-npm
echo prefix=~/.node >> ~/.npmrc
curl -L https://www.npmjs.com/install.sh | sh
echo 'export PATH="$HOME/.node/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
for i in `cat ~/node_modules.txt`;do npm install -g $i;done
rm ~/node_modules.txt

mmizutani commented Aug 30, 2015

In a nutshell:

ls -1 /usr/local/lib/node_modules > ~/node_modules.txt
sed -e "s,/\+$,," -e "s,^/\+,," ~/node_modules.txt
rm -rf /usr/local/lib/node_modules
brew uninstall node --force node
brew install node --without-npm
echo prefix=~/.node >> ~/.npmrc
curl -L https://www.npmjs.com/install.sh | sh
echo 'export PATH="$HOME/.node/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
for i in `cat ~/node_modules.txt`;do npm install -g $i;done
rm ~/node_modules.txt
@jordilondoner

This comment has been minimized.

Show comment
Hide comment
@jordilondoner

jordilondoner Aug 30, 2015

๐Ÿ‘ all good here, thanks!

jordilondoner commented Aug 30, 2015

๐Ÿ‘ all good here, thanks!

@sadethesage

This comment has been minimized.

Show comment
Hide comment
@sadethesage

sadethesage Sep 13, 2015

ilysm, thanks!

sadethesage commented Sep 13, 2015

ilysm, thanks!

@huijing

This comment has been minimized.

Show comment
Hide comment
@huijing

huijing Sep 25, 2015

Following the steps but when I run curl -L https://www.npmjs.com/install.sh | sh I get the following errors:

scripts/installable.sh: line 4: semver: command not found
Packaging or installing npm@3.3.4 with npm@3.3.4 is impossible.
Please install npm@^3.0.0-0 from the registry and use that or run your command with
this version of npm with:
    /usr/local/Cellar/node/4.1.1/bin/node /var/folders/0g/9lxn9c8d3czfj0qvs_qjflxxrn5xph/T/npm.18926/package install -gf
npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/Cellar/node/4.1.1/bin/node" "/private/var/folders/0g/9lxn9c8d3czfj0qvs_qjflxxrn5xph/T/npm.18926/package/cli.js" "install" "-gf"
npm ERR! node v4.1.1
npm ERR! npm  v3.3.4

npm ERR! Maximum call stack size exceeded
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /private/var/folders/0g/9lxn9c8d3czfj0qvs_qjflxxrn5xph/T/npm.18926/package/npm-debug.log
It failed

Does this have to do with the latest update to node?

huijing commented Sep 25, 2015

Following the steps but when I run curl -L https://www.npmjs.com/install.sh | sh I get the following errors:

scripts/installable.sh: line 4: semver: command not found
Packaging or installing npm@3.3.4 with npm@3.3.4 is impossible.
Please install npm@^3.0.0-0 from the registry and use that or run your command with
this version of npm with:
    /usr/local/Cellar/node/4.1.1/bin/node /var/folders/0g/9lxn9c8d3czfj0qvs_qjflxxrn5xph/T/npm.18926/package install -gf
npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/Cellar/node/4.1.1/bin/node" "/private/var/folders/0g/9lxn9c8d3czfj0qvs_qjflxxrn5xph/T/npm.18926/package/cli.js" "install" "-gf"
npm ERR! node v4.1.1
npm ERR! npm  v3.3.4

npm ERR! Maximum call stack size exceeded
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /private/var/folders/0g/9lxn9c8d3czfj0qvs_qjflxxrn5xph/T/npm.18926/package/npm-debug.log
It failed

Does this have to do with the latest update to node?

@nabeel-ibrahim

This comment has been minimized.

Show comment
Hide comment
@nabeel-ibrahim

nabeel-ibrahim Sep 29, 2015

Im getting the same error as @huljing. @huljing did you resolve your issue?

nabeel-ibrahim commented Sep 29, 2015

Im getting the same error as @huljing. @huljing did you resolve your issue?

@mikobiscante

This comment has been minimized.

Show comment
Hide comment
@mikobiscante

mikobiscante Sep 29, 2015

@jitendravyas - open ~/.zshrc, copy & paste export PATH="$HOME/.npm-packages/bin:$PATH" then save.

mikobiscante commented Sep 29, 2015

@jitendravyas - open ~/.zshrc, copy & paste export PATH="$HOME/.npm-packages/bin:$PATH" then save.

@rcastag

This comment has been minimized.

Show comment
Hide comment
@rcastag

rcastag Oct 2, 2015

Amazeballs!

rcastag commented Oct 2, 2015

Amazeballs!

@fabricioflores

This comment has been minimized.

Show comment
Hide comment
@fabricioflores

fabricioflores Oct 3, 2015

I have the same issue as @huijing and @nabeel-ibrahim. Did you find some solution? I thought it was an error of node v4 but I downgraded to v0.12.7 but the issue still persists.
Update
I have noticed that actually there is a version of npm installed. I followed this tutorial and I continued with the next steps after npm install and it works for me.

fabricioflores commented Oct 3, 2015

I have the same issue as @huijing and @nabeel-ibrahim. Did you find some solution? I thought it was an error of node v4 but I downgraded to v0.12.7 but the issue still persists.
Update
I have noticed that actually there is a version of npm installed. I followed this tutorial and I continued with the next steps after npm install and it works for me.

@slemarchand

This comment has been minimized.

Show comment
Hide comment
@slemarchand

slemarchand Oct 8, 2015

Great! It Works fine for me!

slemarchand commented Oct 8, 2015

Great! It Works fine for me!

@skad21

This comment has been minimized.

Show comment
Hide comment
@skad21

skad21 Oct 11, 2015

Very helpfull tips...great, thanks !

skad21 commented Oct 11, 2015

Very helpfull tips...great, thanks !

@imechemi

This comment has been minimized.

Show comment
Hide comment
@imechemi

imechemi Oct 12, 2015

@huijing first export PATH="$HOME/.node/bin:$PATH" and then cd into your project directory or any directory where package.json file exist. semver is a version tester so you can install it once you have package.json file.

imechemi commented Oct 12, 2015

@huijing first export PATH="$HOME/.node/bin:$PATH" and then cd into your project directory or any directory where package.json file exist. semver is a version tester so you can install it once you have package.json file.

@SmellyFish

This comment has been minimized.

Show comment
Hide comment
@SmellyFish

SmellyFish commented Oct 14, 2015

๐Ÿ‘

@ocaoimh

This comment has been minimized.

Show comment
Hide comment
@ocaoimh

ocaoimh Oct 17, 2015

Brilliant. Thanks!

ocaoimh commented Oct 17, 2015

Brilliant. Thanks!

@FredericChang

This comment has been minimized.

Show comment
Hide comment
@FredericChang

FredericChang commented Oct 17, 2015

helpful

@xinpan1992

This comment has been minimized.

Show comment
Hide comment
@xinpan1992

xinpan1992 Oct 20, 2015

Thank you so much!!!!! Your solution helps me solve this problem perfectly!

xinpan1992 commented Oct 20, 2015

Thank you so much!!!!! Your solution helps me solve this problem perfectly!

@Gusbenz

This comment has been minimized.

Show comment
Hide comment
@Gusbenz

Gusbenz Oct 21, 2015

Thanks! This was helpful and useful! Again, thanks!

Gusbenz commented Oct 21, 2015

Thanks! This was helpful and useful! Again, thanks!

@UlisesGascon

This comment has been minimized.

Show comment
Hide comment
@UlisesGascon

UlisesGascon Oct 28, 2015

Thanks! This saved my day!! ๐Ÿ‘

UlisesGascon commented Oct 28, 2015

Thanks! This saved my day!! ๐Ÿ‘

@njv

This comment has been minimized.

Show comment
Hide comment
@njv

njv Oct 29, 2015

Thank you!

njv commented Oct 29, 2015

Thank you!

@mattsilv

This comment has been minimized.

Show comment
Hide comment
@mattsilv

mattsilv Nov 2, 2015

thank you. Worked well on OSX 10.10

mattsilv commented Nov 2, 2015

thank you. Worked well on OSX 10.10

@fwahlqvist

This comment has been minimized.

Show comment
Hide comment
@fwahlqvist

fwahlqvist Nov 2, 2015

Thanks ๐Ÿ‘

fwahlqvist commented Nov 2, 2015

Thanks ๐Ÿ‘

@obouchari

This comment has been minimized.

Show comment
Hide comment
@obouchari

obouchari Nov 3, 2015

Thanks! ๐Ÿ‘

obouchari commented Nov 3, 2015

Thanks! ๐Ÿ‘

@MikaelCarpenter

This comment has been minimized.

Show comment
Hide comment
@MikaelCarpenter

MikaelCarpenter Nov 4, 2015

getting -bash: /usr/local/bin/npm: No such file or directory any ideas?

MikaelCarpenter commented Nov 4, 2015

getting -bash: /usr/local/bin/npm: No such file or directory any ideas?

@FullstackJack

This comment has been minimized.

Show comment
Hide comment
@FullstackJack

FullstackJack Nov 5, 2015

Thanks, but I had to do the following to get mine to install all the way:

cd ~
rm -rf /usr/local/lib/node_modules
brew uninstall node
brew install node --without-npm
echo prefix=~/.node >> ~/.npmrc
sudo chown -R $(whoami) /usr/local
brew link --overwrite  node
curl -L https://www.npmjs.com/install.sh | sh

Permission Denied will occur if calling curl from a directory you don't have write permissions. I didn't realize I was in the wrong directory at first and foolishly kept making that mistake while searching for solutions.

FullstackJack commented Nov 5, 2015

Thanks, but I had to do the following to get mine to install all the way:

cd ~
rm -rf /usr/local/lib/node_modules
brew uninstall node
brew install node --without-npm
echo prefix=~/.node >> ~/.npmrc
sudo chown -R $(whoami) /usr/local
brew link --overwrite  node
curl -L https://www.npmjs.com/install.sh | sh

Permission Denied will occur if calling curl from a directory you don't have write permissions. I didn't realize I was in the wrong directory at first and foolishly kept making that mistake while searching for solutions.

@opfertunes

This comment has been minimized.

Show comment
Hide comment
@opfertunes

opfertunes Nov 10, 2015

You sir ROCK

opfertunes commented Nov 10, 2015

You sir ROCK

@jiyinyiyong

This comment has been minimized.

Show comment
Hide comment
@jiyinyiyong

jiyinyiyong Nov 11, 2015

I actually fixed my npm with this:

brew postinstall node

http://forums.webhook.com/t/bash-npm-command-not-found-resolved/66/7

jiyinyiyong commented Nov 11, 2015

I actually fixed my npm with this:

brew postinstall node

http://forums.webhook.com/t/bash-npm-command-not-found-resolved/66/7

@DavidJBarnes

This comment has been minimized.

Show comment
Hide comment
@DavidJBarnes

DavidJBarnes Nov 12, 2015

Thanks you!!

DavidJBarnes commented Nov 12, 2015

Thanks you!!

@backspaces

This comment has been minimized.

Show comment
Hide comment
@backspaces

backspaces Nov 12, 2015

Boy, this makes me feel uneasy. All my hacking uses node/npm daily. I currently have the install from their site, done using the npm trick of not using admin directories: https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md

Brew doctor gives me the list of 110 /usr/local/include/node header files. Sigh.

So you promise that if I remove the node/npm site's install, along with the global npm modules, then do as suggested to use homebrew for managing node/npm .. mainly npm .. I'll be able to update both node and npm via homebrew safely?

You mention also deleting all the global installs. What about the --save and --save-dev local developer npm package installs? Do I have to also delete them? I.e. when I update them, will they fail, or just work, only global packages are at risk?

How in the world did we get into this mess! Sorry to be grouchy, and thanks for the help. A LOT! :)