在Mac中安装cordova时出错

时间:2015-02-24 13:54:53

标签: node.js cordova

CFL2-WS-06:~ aamirkhan$ npm install -g cordova ios-deploy 
npm ERR! tar.unpack untar error /Users/aamirkhan/.npm/ios-deploy/1.3.2/package.tgz
npm ERR! tar.unpack untar error /Users/aamirkhan/.npm/cordova/4.2.0/package.tgz
npm ERR! Darwin 14.1.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "cordova" "ios-deploy"
npm ERR! node v0.12.0
npm ERR! npm  v2.5.1
npm ERR! path /usr/local/lib/node_modules/ios-deploy
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/ios-deploy'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/ios-deploy']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/usr/local/lib/node_modules/ios-deploy',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/usr/local/lib/node_modules/ios-deploy',
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!      'FSReqWrap.oncomplete (fs.js:99: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!     /Users/aamirkhan/Desktop/npm-debug.log

1 个答案:

答案 0 :(得分:5)

编辑:

由于答案有5个upvotes,我建议在安装cordova或其他NPM软件包时不要使用sudo,并将节点安装更改为不需要sudo。

有几种选择:

  1. 使用nvm
  2. 使用自制程序安装节点
  3. 修复npm权限https://docs.npmjs.com/getting-started/fixing-npm-permissions
  4. 老答案:

    您无权编写,请使用sudo命令

    sudo npm install -g cordova ios-deploy
    

    然后输入您的密码