npm 的使用总结

一、新域名

  • 官方地址 : https://npmmirror.com
  • 镜像地址 : https://registry.npmmirror.com
  • 老域名:http://npm.taobao.org 和 http://registry.npm.taobao.org 将在 2022.06.30 号正式下线和停止 DNS 解析

  原来的 registry.npm.taobao.org 已替换为 registry.npmmirror.com ,当点击 registry.npm.taobao.org 会默认跳转到 registry.npmmirror.com

二、npm镜像源

1. 设置镜像源:--registry 临时使用镜像;registry 持久配置镜像。

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

2. 查看当前使用的镜像地址:

npm config get registry

3.还原为国外地址:

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

4. 使用专门为加速 npm 设计的工具:例如 cnpm 和 nrm

npm install cnpm -g

 5、清空缓存

npm cache clean --force

 

执行cnpm install lodash,会在node_modules文件夹下生成两个文件夹:_lodash@4.17.11@lodashlodash

cnpm安装的2个模块,两者存在引用关系
实测发现,尽管使用npm改成淘宝仓库,发现安装速度还是远远比cnpm慢(当模块比较多的时候)。应该和cnpm安装的文件结构有关系。

 

 

参考地址:https://blog.csdn.net/sunhuaqiang1/article/details/118191084

posted @ 2024-01-19 18:27  小阿飞ZJF  阅读(22)  评论(0编辑  收藏  举报