当我尝试使用 yo 生成器sudo yo meanjs
安装一个 meanjs 模板时,它会给我这个错误:
/usr/local/lib/node_modules/yo/node_modules/write-file-atomic/index.js:236
throw err
^
**Error: EACCES: permission denied, open '/home/myname/.config/insight-nodejs/insight-yo.json.1173957578'**
<br> at Object.fs.openSync (fs.js:646:18)
at Function.writeFileSync [as sync] (/usr/local/lib/node_modules/yo/node_modules/write-file-atomic/index.js:212:13)
<br> at Conf.set store [as store] (/usr/local/lib/node_modules/yo/node_modules/conf/index.js:142:19)
at Conf.set (/usr/local/lib/node_modules/yo/node_modules/conf/index.js:64:14)
at Insight.set optOut [as optOut] (/usr/local/lib/node_modules/yo/node_modules/insight/lib/index.js:56:15)
<br>at Object.<anonymous> (/usr/local/lib/node_modules/yo/lib/cli.js:206:18)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
我的全局nodejs模块是:
'ls -la/usr/local/lib/node_modules 总计 52'
drwxr-xr-x 13 root root 4096 ديسمب 7 18:01 .
- drwxr-xr-x 5 root root 4096 أكتوب 21 09:53 ..
- drwxr-xr-x 4 nobody ayoub 4096 ديسمب 7 17:54 bower
- drwxr-xr-x 5 nobody ayoub 4096 أكتوب 21 09:59 electron
- drwxr-xr-x 5 nobody ayoub 4096 ديسمب 6 16:42 express-generator
- drwxr-xr-x 19 nobody ayoub 4096 ديسمب 7 18:01 generator-meanjs
- drwxr-xr-x 5 nobody ayoub 4096 نوفمب 8 11:54 grunt
- drwxr-xr-x 6 nobody ayoub 4096 نوفمب 8 11:52 grunt-cli
- drwxr-xr-x 4 nobody ayoub 4096 نوفمب 6 21:15 gulp
- drwxr-xr-x 6 nobody ayoub 4096 نوفمب 8 16:16 gulp-cli
- drwxr-xr-x 5 nobody ayoub 4096 نوفمب 12 14:10 mern-app-generator
- drwxr-xr-x 4 nobody ayoub 4096 نوفمب 8 16:43 yarn
- drwxr-xr-x 4 nobody ayoub 4096 ديسمب 7 17:56 yo
我的操作系统是:ubuntu 18.04
似乎 root 用户无法访问此文件。 在命令为我行走之前删除sudo
。我的意思是,试试yo meanjs
你能试试这个:
sudo npm install -g yo --unsafe-perm=true --allow-root
然后运行命令以创建应用程序
sudo yo meanjs
如果仍然收到错误,请尝试以下操作:
chown -R $USER $HOME/.npm
sudo chown -R $USER /usr/local/lib/node_modules/yo
sudo yo meanjs
在这里阅读更多 :
https://github.com/krakenjs/generator-kraken/issues/114#issuecomment-54201366
Ubuntu - nodejs - npm install -g> 错误: EACCES: 权限被拒绝, mkdir
尝试以下命令
sudo chown -R $USER:$(id -gn $USER) /home/myname/.config