1
2
3
npm config proxy socks5://127.0.0.1:1080
npm config https-proxy socks5://127.0.0.1:1080
# 上面两个也可以使用 npm config edit 进行记事本编辑

但上面设置好了之后,遇到了

1
2
npm ERR!       E418
npm ERR! 418 I'm a teapot:

看到how-do-i-solve-the-npm-418-im-a-teapot-error-when-trying-to-use-npm-install说要将npmrcregistryURL从http协议改成https

1
npm config set registry https://registry.npmjs.org/

改了之后确实有效