Installing electron globally on Ubuntu with NPM

别来无恙 提交于 2019-12-18 09:38:32

问题


Attempting to resolve this question and getting the following error when installing electron globally with 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

回答1:


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. :-)



来源:https://stackoverflow.com/questions/48593682/installing-electron-globally-on-ubuntu-with-npm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!