2

I'm trying to get set up on a project with Gulp.js when I run the command:

npm install gulp --save-dev

I get the errors:

npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
npm WARN package.json [email protected] No README data
npm ERR! Error: EACCES, chown '/path/to/dir/htdocs/node_modules/gulp/package.json'
npm ERR! at Error (native)
npm ERR! { [Error: EACCES, chown '/path/to/dir/htdocs/node_modules/gulp/package.json']
npm ERR! stack: 'Error: EACCES, chown \'/path/to/dir/htdocs/node_modules/gulp/package.json\'\n at Error (native)',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! path: '/path/to/dir/htdocs/node_modules/gulp/package.json',
npm ERR! fstream_finish_call: 'chown',
npm ERR! fstream_type: 'File',
npm ERR! fstream_path: '/path/to/dir/htdocs/node_modules/gulp/package.json',
npm ERR! fstream_class: 'FileWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js:308:19',
npm ERR! '/usr/local/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:143:7',
npm ERR! 'Object.oncomplete (evalmachine.<anonymous>:93:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Linux 3.0.0-12-generic-pae
npm ERR! command "node" "/usr/local/bin/npm" "install" "gulp" "--save-dev"
npm ERR! cwd /path/to/dir/htdocs
npm ERR! node -v v0.13.0-pre
npm ERR! npm -v 1.4.26
npm ERR! path /path/to/dir/htdocs/node_modules/gulp/package.json
npm ERR! fstream_path /path/to/dir/htdocs/node_modules/gulp/package.json
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! fstream_finish_call chown
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! stack Error: EACCES, chown '/path/to/dir/htdocs/node_modules/gulp/package.json'
npm ERR! stack at Error (native)
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js:308:19
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:143:7
npm ERR! fstream_stack Object.oncomplete (evalmachine.<anonymous>:93:15)
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /path/to/dir/htdocs/npm-debug.log
npm ERR! not ok code 0

Here is my package.json file

{
 "name": "htdocs",
 "version": "0.0.0",
 "description": "",
 "main": "gulpfile.js",
 "dependencies": {
 "gulp": "^3.8.8",
 "gulp-uglify": "1.0.1"
 },
 "devDependencies": {
 "gulp": "^3.8.8",
 "gulp-uglify": "1.0.1"
 },
 "scripts": {
 "test": "echo \"Error: no test specified\" && exit 1"
 },
 "author": "",
 "license": "ISC"
}

I found a few people with similar issues online and the fixes suggested running the command:

sudo chown -R whoami ~/.npm But this has not solved the issue in my case.

Does anyone have an idea what the cause of this could be and a solution?

asked Sep 12, 2014 at 15:17

3 Answers 3

2

I had the same issue on OSX, I fixed it executing:

sudo chown -R $USER:$GROUP ~/.npm

and:

npm cache clean

Then I could install the package with --save-dev in the project.

Source: https://github.com/npm/npm/issues/5869

answered Jan 15, 2015 at 10:46
0

npm must be able to write into the path /path/to/dir/htdocs/node_modules/, where (your) node writes its modules.

You have two frequently-used options to fix these permissions:

  • Install one gulp for everyone

    sudo npm install -g gulp
    
  • Save gulp for project

    (sudo if necessary) chmod u+rw /path/to/dir/htdocs/node_modules/
    npm install gulp --save-dev
    

    You may also need to fix permissions for parent directories.

If anyone else has a better idea, please also let me know.

answered Sep 13, 2014 at 13:44
0

running npm install npm@latest -g and updating to the latest version solved the issue for me :)

answered Jul 4, 2017 at 15:12

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.