使用NPM在Ubuntu上全局安装电子 [英] Installing electron globally on Ubuntu with NPM

查看:196
本文介绍了使用NPM在Ubuntu上全局安装电子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试解决这个问题并得到使用NPM全局安装电子时出现以下错误:

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

推荐答案

npm提议:

 mkdir ~/.npm-global
 npm config set prefix '~/.npm-global'
 export PATH=~/.npm-global/bin:$PATH
 source ~/.profile

通过这样做,您可以将全局npm软件包保留在用户帐户范围内,而不是在计算机中的所有用户之间共享.即使您是唯一的用户,也建议这样做. :-)

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

这篇关于使用NPM在Ubuntu上全局安装电子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆