成都创新互联网站制作重庆分公司

npm全局安装包已经sudo仍然没有权限的解决方法

想全局安装electron却提示我没有权限:

创新互联于2013年创立,是专业互联网技术服务公司,拥有项目做网站、网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元泉港做网站,已为上家服务,为泉港各地企业和个人服务,联系电话:18982081108

sudo npm install -g electron

Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/electron/electron-tmp-download-1374-1511880539207'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! electron@1.7.9 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the electron@1.7.9 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!     /Users/pomelo/.npm/_logs/2017-11-28T14_49_00_758Z-debug.log

这就很奇怪了,去electron的github的issue里找到了解决办法,需要把npm相关的目录的权限转移到当前用户来:

官方解决:https://docs.npmjs.com/getting-started/fixing-npm-permissions

之后安装会卡在node install.js这里,需要换国内的镜像,编辑/.npmrc:

electron_mirror=https://npm.taobao.org/mirrors/electron/


文章名称:npm全局安装包已经sudo仍然没有权限的解决方法
URL链接:http://cxhlcq.com/article/ihedeh.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部