brew: Can't upgrade npm within node@4 on fresh brew install with its only package
Much has been said about brew/node/npm and permissions problems. Today I’ve encountered a configuration I haven’t seen before, so maybe it’s worth reporting.
Prerequisite: completely pristine OSX, no previous Homebrew files around
- Install brew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - Observe that
/usr/local/libis empty - Install node4:
brew install node@4 - Observe that there is now
/usr/local/lib/node_modules/ - Run
npm install -g npm
💥
npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/Cellar/node@4/4.8.0/bin/node" "/usr/local/bin/npm" "install" "-g" "npm"
npm ERR! node v4.8.0
npm ERR! npm v2.15.11
npm ERR! path /usr/local/lib
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rmdir
npm ERR! Error: EACCES: permission denied, rmdir '/usr/local/lib'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES: permission denied, rmdir '/usr/local/lib']
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rmdir',
npm ERR! path: '/usr/local/lib' }
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! /Users/user/npm-debug.log
At this point things are completely foobar because npm and node_modules were removed and no other version installed.
A quick fix is to uninstall/install the brew package:
brew uninstall node@4 && brew install node@4
Fun fact: if there is anything else in /usr/local/lib/, it works!
Same procedure as above, with a new 5):
- Install brew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" - Observe that
/usr/local/libis empty - Install node4:
brew install node@4 - Observe that there is now
/usr/local/lib/node_modules/ touch /usr/local/lib/dummy- Run
npm install -g npm
Everything works 🚀
It is my understanding this is more likely a problem of how npm itself works and not a brew issue.
Note that this is when upgrading from node4’s npm which is version 2.
I did not encounter such problems when I manually jumped e.g. from npm 4 to 3 or such, so this seems not a current bug of npm anymore.
But since an older version of npm is installed here, maybe brew can do something as a workaround.
thanks!
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 26 (24 by maintainers)
@DomT4 the following changes have been made:
node@0.10: made non-keg_only, conflicts with node and node@0.12 added. node@0.12: made non-keg_only, conflicts with node and node@0.10 added. node@4: npm upgraded to 4.1.2. node@5: deleted. node@6: npm upgraded to 4.1.2. node: conflicts with node@0.10 and node@0.12 added.
Revision bumps all around.
Why do you need to run this, out of interest?