尝试解决this question并在使用NPM全局安装电子时出现以下错误:
ole@mki:~/angular-electron$ sudo npm install electron -g
/usr/bin/electron -> /usr/lib/node_modules/electron/cli.js
> electron@1.7.12 postinstall /usr/lib/node_modules/electron
> node install.js
/usr/lib/node_modules/electron/install.js:48
throw err
^
Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/electron/dist'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron@1.7.12 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron@1.7.12 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ole/.npm/_logs/2018-02-03T03_28_15_952Z-debug.log
答案 0 :(得分:3)
As npm proposes:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
source ~/.profile
By doing it this was you keep your global npm packages scoped within your user account, instead of shared between all the users in the computer. Even if you're the only user, this is a recommended behavior. :-)