Error installing Gulp

I'm new to using terminal and installing gulp, but I have a few errors. Errors keep popping up and I'm not sure why. My goal now is to install gulp globally, but not sure if any old files are getting in the way. Maybe a clean and reinstall will work? The error is below. Thank you!

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

      

+3


source to share


2 answers


Other answers work around these problems with sudo

or su root

. I personally don't recommend this. The reason this works is because on OSX the global npm module directory has stricter permissions. Running your commands with root privileges just to get around permission issues is likely to give you headaches on the road and expose you to security vulnerabilities. At the very least, it will end up using it all the sudo

time when trying to do your normal node / npm actions. A safer way would be to change the permissions of this particular directory. However, even this can sometimes cause nightmares.

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

You can install it using curl (you have this, just paste the following command):

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

      

Or you can use Homebrew if you have:



brew install nvm

      

Once installed, you should be able to easily install any version of node or iojs you want.

nvm install node

      

The instructions above will install the latest version of node. The nice part is that all of your node / iojs installations are managed within ~/.nvm/

, meaning they are inside your home directory where you will always have full permissions and never use sudo

.

+4


source


You have no permission to write un / sur / local Either you run sudo npm install -g gulp

or grant the user write permission to / usr / local



+1


source







All Articles