关于 npm 与 yarn 对比可以参考此篇 《Yarn vs npm:你需要知道的一切》
了解 npm,可参考此篇《什么是 npm》
npm
1.npm 查看版本
npm 版本
npm -v
node 版本
node -v
2.npm 清除缓存
npm cache clean --force
3.npm install 不自动添加前缀
// 默认使用前缀~
npm config set save-prefix '~'
// 不使用前缀,保存确切版本
npm config set save-exact true
4.npm 设置代理
添加:注意 proxy 是别名,可设置多个
// yarn config set proxy <http_proxy>
npm config set proxy http://61.183.129.187:8093/repository/npm-public/
删除
npm config delete proxy
建议使用插件 nrm ,参考此篇《工具:nrm》
5.node 对应的 npm 版本
yarn
1.yarn 设置代理
添加
// yarn config set my-public <http_proxy>
yarn config set my-public http://192.168.52.55:8081/repository/npm-public/
删除
yarn config delete my-public