Node配置

国内优秀npm镜像推荐及使用

淘宝npm镜像

临时使用

1
npm --registry https://registry.npm.taobao.org install express

持久使用

1
2
3
4
5
6
npm config set registry https://registry.npm.taobao.org

// 配置后可通过下面方式来验证是否成功
npm config get registry
// 或
npm info express

通过cnpm使用

1
2
3
4
npm install -g cnpm --registry=https://registry.npm.taobao.org

// 使用
cnpm install express

https://blog.niceue.com/front-end-development/using-domestic-npm-images.html

1
2
3
4
# 配置 registry
npm config set registry https://r.cnpmjs.org/
# 验证配置是否修改成功
npm config get registry

npm install

If you have a package.json file in your directory and you run npm install,
then npm will look at the dependencies that are listed in that file and
download the latest versions satisfying semver rules for all of those.
https://docs.npmjs.com/getting-started/using-a-package.json

修改npm install -g 的安装目录

查看: npm root -g
修改:在配置文件中 .npmrc 中添加,prefix = "D:\\c\\nodejs\\node_modules\\npm"