Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error installing Gulp

I am pretty new to using terminal and installing gulp, but I am running through a few errors. Errors keep popping up and I am not sure why. My goal for right now is to install gulp globally, but not sure if any old files are interfering. Maybe a clean out and reinstall would work? Error is below. Thanks!

pm ERR! tar.unpack untar error /Users/.npm/gulp/3.9.0/package.tgz
npm ERR! Darwin 14.1.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "gulp"
npm ERR! node v0.12.4
npm ERR! npm  v2.10.1
npm ERR! path /usr/local/lib/node_modules/gulp
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/gulp'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/gulp']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/gulp',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/gulp',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:35:25',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53',
npm ERR!      'FSReqWrap.oncomplete (fs.js:95:15)' ] }
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!     /usr/local/bin/npm-debug.log
like image 273
cesar gomez Avatar asked Jun 05 '15 18:06

cesar gomez


2 Answers

Other answers are bypassing these issues by the use of sudo or su root. I personally don't recommend this. The reason it works is because on OSX the global npm module directory has stricter permissions. Running your commands with root privileges just to get around permissions issues is likely only going to cause you headaches down the road and open you up to security vulnerabilities. At the very least it's going to cause you to have to use sudo constantly when trying to do routine node/npm things. The safer way would be to change the permissions of just that directory. However, even that can sometimes cause nightmares.

My alternative recommendation to the other suggestions here is to use nvm.

You can install it with curl (you have this already, just paste the below command):

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash

Or you can use Homebrew if you have that installed:

brew install nvm

Once installed, you'll be able to easily install any node or iojs version that you want.

nvm install node

The above command will install the latest version of node. The nice part is that all your node/iojs installations are managed within ~/.nvm/, meaning they are inside your home directory where you'll always have full access permissions and won't ever need to use sudo.

like image 90
Chev Avatar answered Sep 22 '22 06:09

Chev


You dont have the rights to write un /sur/local Either you run sudo npm install -g gulp or give your user the rights to write in /usr/local

like image 36
Pierre Inglebert Avatar answered Sep 22 '22 06:09

Pierre Inglebert