1.临时使用
npm --registry https://registry.npm.taobao.org install express
2.持久使用
npm config set registry https://registry.npm.taobao.org
配置后可通过下面方式来验证是否成功
npm config get registry 或 npm info express
3.通过cnpm使用
npm install -g cnpm --registry=https://registry.npm.taobao.org
4、使用cnpm
cnpm install xxx
5、升级cnpm淘宝镜像为最新版本
npm install npm@latest -g cnpm --registry=http://registry.npm.taobao.org
6、用npm命令使用淘宝镜像
npm自身就默认代的镜像:http://registry.npmjs.org
npm config set registry http://registry.npmjs.org
如果用npm命令使用淘宝镜像,再次修改为npm的淘宝链接:
npm config set registry http://registry.npm.taobao.org
7、cnpm命令没反应
1、cnpm -v、cnpm install等等cnpm命令执行了都只是跳到下一行就毫无反应。试了npm是没问题的
2、上百度搜了下列三种方式尝试都还是不行
设置环境变量。没用
删除C盘用户目录下的.npmrc文件。也没有用
执行npm config set registry http://registry.cnpmjs.org。还是没用
3、就试着卸载cnpm重新安装试试,果然可以了
卸载 npm uninstall -g cnpm --registry=https://registry.npm.taobao.org
注册 npm set registry https://registry.npm.taobao.org
解析 npm set disturl https://npm.taobao.org/dist
安装 npm install -g cnpm --registry=https://registry.npm.taobao.org