qiu8310 / smart-npm

Auto switch registry according your npm command.
328 stars 31 forks source link

无法安装成功 #68

Closed edwinhuish closed 7 years ago

edwinhuish commented 7 years ago

请看下面的错误: 运行环境是 virtualbox, ubuntu 17.04 32bit, node v8.0.0, npm 5.0.3

edwin@edwin-VirtualBox:~$ sudo npm install --global smart-npm --registry=https://registry.npm.taobao.org/

> smart-npm@3.0.1 preinstall /usr/local/lib/node_modules/smart-npm
> npm config set registry https://registry.npm.taobao.org/

npm ERR! path /usr/local/etc/npmrc
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall open
npm ERR! Error: EACCES: permission denied, open '/usr/local/etc/npmrc'
npm ERR!  { Error: EACCES: permission denied, open '/usr/local/etc/npmrc'
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'open',
npm ERR!   path: '/usr/local/etc/npmrc' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

┌─────────────────────────────────────────────────────────┐
│                 npm update check failed                 │
│           Try running with sudo or get access           │
│          to the local update config store via           │
│ sudo chown -R $USER:$(id -gn $USER) /home/edwin/.config │
└─────────────────────────────────────────────────────────┘

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/edwin/.npm/_logs/2017-06-14T12_57_16_538Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 243
npm ERR! smart-npm@3.0.1 preinstall: `npm config set registry https://registry.npm.taobao.org/`
npm ERR! Exit status 243
npm ERR! 
npm ERR! Failed at the smart-npm@3.0.1 preinstall 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/edwin/.npm/_logs/2017-06-14T12_57_38_699Z-debug.log
edwinhuish commented 7 years ago

已用sudo,也测试过sudo chown -R edwin /home/edwin/.config

qiu8310 commented 7 years ago

你手动运行 npm config set registry https://registry.npm.taobao.org/ 呢,也会有错吗?

不过我可以优雅处理一下,上面的命令执行失败也不是很重要,但现在会导致安装不成功。

edwinhuish commented 7 years ago

npm config set registry https://registry.npm.taobao.org/

这个早设置了,一直在用

miaowm5 commented 7 years ago

看这个解决方案: https://docs.npmjs.com/getting-started/fixing-npm-permissions#option-2-change-npms-default-directory-to-another-directory

edwinhuish commented 7 years ago

后来装了双系统,没有这个问题,貌似仅仅是VM才会遇到的问题。