错误的ERR!请尝试以root / Administrator身份再次运行此命令

时间:2014-10-20 21:16:35

标签: cordova npm ionic-framework

试图让离子启动并运行但是会遇到很多错误。任何提示?

Nates-MacBook-Pro:~ TheRainmaker$ npm install -g cordova ionic
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/cordova'
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/cordova']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/cordova',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/cordova',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53',
npm ERR!      'Object.oncomplete (fs.js:107:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 14.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "cordova" "ionic"
npm ERR! cwd /Users/TheRainmaker
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! path /usr/local/lib/node_modules/cordova
npm ERR! fstream_path /usr/local/lib/node_modules/cordova
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules/cordova'
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/ionic'
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/ionic']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/ionic',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/ionic',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack: 
npm ERR!    [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR!      '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53',
npm ERR!      'Object.oncomplete (fs.js:107:15)' ] }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 14.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "cordova" "ionic"
npm ERR! cwd /Users/TheRainmaker
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! path /usr/local/lib/node_modules/ionic
npm ERR! fstream_path /usr/local/lib/node_modules/ionic
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules/ionic'
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/TheRainmaker/npm-debug.log
npm ERR! not ok code 0
Nates-MacBook-Pro:~ TheRainmaker$ 

3 个答案:

答案 0 :(得分:10)

尝试这个

sudo npm install -g cordova ionic

答案 1 :(得分:4)

安装可以运行任意脚本并使用sudo运行它可能非常危险。

将/ usr / local文件夹中文件的所有者更改为当前用户:

sudo chown -R $USER /usr/local

然后运行安装

npm install -g cordova ionic

退房:

答案 2 :(得分:1)

使用root / administrator访问从Internet运行脚本是个坏主意。您应该将npm模块的默认安装路径更改为其他文件夹。

在linux上你应该使用

echo prefix=${HOME}/.localnpm >> ~/.npmrc

这将使npm将所有内容安装到~/.localnpm/bin~/.localnpm/lib