2

嗨,我正在尝试使用 npm 安装cordova

sudo npm install -g cordova

我有这个错误

npm ERR! Error: EACCES, symlink '../lib/node_modules/cordova/bin/cordova'
npm ERR!  { [Error: EACCES, symlink '../lib/node_modules/cordova/bin/cordova']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '../lib/node_modules/cordova/bin/cordova' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 11.4.2
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "cordova"
npm ERR! cwd /Users/yannickghilardi
npm ERR! node -v v0.10.21
npm ERR! npm -v 1.3.11
npm ERR! path ../lib/node_modules/cordova/bin/cordova
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, symlink '../lib/node_modules/cordova/bin/cordova'
npm ERR! Error: EACCES, open 'npm-debug.log'
npm ERR!  { [Error: EACCES, open 'npm-debug.log'] errno: 3, code: 'EACCES', path:  'npm-debug.log' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 11.4.2
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "cordova"
npm ERR! cwd /Users/yannickghilardi
npm ERR! node -v v0.10.21
npm ERR! npm -v 1.3.11
npm ERR! path npm-debug.log
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, open 'npm-debug.log'
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/yannickghilardi/npm-debug.log
npm ERR! not ok code 0

然后我尝试使用这个命令 sudo chown -R yannickghilardi /usr/local/lib/node_modules 我有这个错误信息

Operation not permitted

这个问题有解决方案吗?提前致谢

4

2 回答 2

6

刚才我解决了这个问题。通过进入根文件夹执行此命令。

目标文件夹 --> /usr/local/lib/node_modules/并输入命令sudo npm install -g cordova

于 2013-12-30T11:59:02.740 回答
0

我尝试使用命令安装npm i -g cordova-res --unsafe-perm。它工作得很好。

于 2019-08-05T12:10:50.313 回答