我試圖讓建立與Gulp.js一個項目,當我運行命令:NPM安裝一飲而盡--save-dev的錯誤
npm install gulp --save-dev
我得到的錯誤:
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
這裏是我的package.json文件
{
"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"
}
我發現有幾個人有類似的問題在網上和修復建議運行以下命令:
sudo chown -R
whoami
〜/ .npm 但是這並沒有解決我的問題。
有沒有人有一個想法,這可能是什麼原因和解決方案?