Error installing Gulp
Asked Answered
R

2

6

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
Rutile answered 5/6, 2015 at 18:11 Comment(4)
Don't let the downvotes deter you from sticking around and asking more questions. Your issue is a common issue and easily solved :). See my answer below, or if you don't mind typing sudo a lot then the other answers are valid as well :)Deoxyribonuclease
@AlexFord Thank you Alex :) Yea I am not sure why my question got downvoted. I installed homebrew before trying to install gulp, but didn't run into this error until I tried to do a global install. I will definitely try this out and get back at you to see if I can get through this issue. Thank you so much! :)Rutile
You're welcome:). Nvm will definitely solve your issue with global installs via npm. As an aside, if you install nvm via Homebrew then make sure to read the text in the terminal after you install it and follow the instructions. It's a couple quick little steps but easily missed if you ignore it like I often do :P. It tells you to add a couple lines to your .bashrc file. Note that on OSX you'll actually want to add those lines to ~/.bash_profile.Deoxyribonuclease
Don't forget to mark the answer that helped you as accepted :)Deoxyribonuclease
D
6

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.

Deoxyribonuclease answered 5/6, 2015 at 20:20 Comment(1)
It should be noted that it's not just about headaches but creates a major security vulnerability. Don't ever use sudo to install node packages.Sidney
C
1

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

Concettaconcettina answered 5/6, 2015 at 18:22 Comment(1)
Installing a package this way completely opens up your entire file system to the node package. Even if the creator has no malicious intent a small bug in their code could level your entire file system.Sidney

© 2022 - 2024 — McMap. All rights reserved.