如何解决cordova安装问题

时间:2014-03-14 16:29:24

标签: ios cordova

我正在尝试使用终端创建cordova,但我收到了以下错误。 到目前为止,我知道这是我们创建且完整的唯一用户帐户 是root帐户

install -g cordova
npm http GET https://registry.npmjs.org/cordova
npm http 304 https://registry.npmjs.org/cordova
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:37: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 12.5.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "cordova"
npm ERR! cwd /Users/anantmac
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
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:37: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/anantmac/npm-debug.log
npm ERR! not ok code 0
Anants-MacBook-Air:~ anantmac$ 

1 个答案:

答案 0 :(得分:3)

有时在安装节点包时,您需要使用sudo,这样一切都可以写入所需的路径,试试这个:

sudo npm install -g cordova