`npm install -g gulp bower` errors

I have been banging my head against the wall trying to get gulp and bower working. I’ve been a regular user of Roots/Sage for 3 years and love it. However, I recently ran a dev environment setup script for a work application and it broke gulp.

I’ve tried a million things including removing npm and re-installing it, running various things as sudo, etc. I eventually threw my hands up and reformatted and reinstalled OS X (El Cap) thinking this would fix it, but it did not (possibly because I restored from a backup).

Anyway, here is the error I get when I run npm install -g gulp bower as indicated in the docs:

npm ERR! Darwin 15.4.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "gulp" "bower"
npm ERR! node v4.4.3
npm ERR! npm  v2.15.1
npm ERR! path /Users/David/.npm-packages/lib/node_modules/bower/CHANGELOG.md
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall unlink

npm ERR! Error: EACCES: permission denied, unlink '/Users/David/.npm-packages/lib/node_modules/bower/CHANGELOG.md'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES: permission denied, unlink '/Users/David/.npm-packages/lib/node_modules/bower/CHANGELOG.md']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'unlink',
npm ERR!   path: '/Users/David/.npm-packages/lib/node_modules/bower/CHANGELOG.md' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
npm ERR! error rolling back Error: EACCES: permission denied, unlink '/Users/David/.npm-packages/lib/node_modules/bower/CHANGELOG.md'
npm ERR! error rolling back     at Error (native)
npm ERR! error rolling back  { [Error: EACCES: permission denied, unlink '/Users/David/.npm-packages/lib/node_modules/bower/CHANGELOG.md']
npm ERR! error rolling back   errno: -13,
npm ERR! error rolling back   code: 'EACCES',
npm ERR! error rolling back   syscall: 'unlink',
npm ERR! error rolling back   path: '/Users/David/.npm-packages/lib/node_modules/bower/CHANGELOG.md' }

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/David/npm-debug.log

I’d appreciate any help you can offer. Otherwise I’ll try reformatting again without restoring from backup.

Thanks in advance,
David

I’d probably uninstall again (see here) and then use nvm as seen here: Npm Debugging Guidelines (Failed npm install, bower install, or gulp build? Read this)

Thanks @swalkinshaw. That did seem to fix it, but now I keep getting command not found when using npm, nvm, or gulp commands.

I have to run . ~/.nvm/nvm.sh every time I open a new terminal window, and then the above commands work. I added the source lines to my .bashrc, .profile, and .zshrcas instructed but this seems to have no effect.

This is what my .bashrc looks like:

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"

export NVM_DIR="/Users/David/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm

and .profile:

PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting

export NVM_DIR="/Users/David/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm

Any advice?

Try StackOverflow… this isn’t the place to get support for getting Node.js up and running.

FWIW, here’s my ~/.bash_profile :

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

alias fucking='sudo'
alias fuck='$(thefuck $(fc -ln -1))';

export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh

export PATH="~/.composer/vendor/bin:$PATH"

[[ -s $(brew --prefix)/etc/profile.d/autojump.sh ]] && . $(brew --prefix)/etc/profile.d/autojump.sh

1 Like

Thanks @paul_tibbetts. I seem to have overlooked ~/.bash_profile. I added the following to mine and now it works:

[[ -s "$HOME/.profile" ]] && source "$HOME/.profile"
export NVM_DIR=~/.nvm
2 Likes