首页 前端知识 npm使用国内淘宝镜像的方法(两种)

npm使用国内淘宝镜像的方法(两种)

2024-08-10 22:08:44 前端知识 前端哥 1971 401 我要收藏

一、通过命令配置

1、设置淘宝镜像源

npm config set registry https://registry.npmmirror.com/
复制

2、设置官方镜像源

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

3、查看镜像使用状态:

npm config get registry
复制

如果返回https://registry.npmmirror.com/,说明配置的是淘宝镜像。

如果返回https://registry.npmjs.org/,说明配置的是官方镜像。

二、通过使用cnpm安装

1、安装cnpm

npm install -g cnpm --registry=https://registry.npmmirror.com
解决安装卡顿或无法安装:
# 注册模块镜像
npm set registry https://registry.npmmirror.com
// node-gyp 编译依赖的 node 源码镜像
npm set disturl https://npmmirror.com/dist
// 清空缓存
npm cache clean --force
// 安装cnpm
npm install -g cnpm --registry=https://registry.npmmirror.com
复制

2、使用cnpm

cnpm install xxx
复制

转载请注明出处或者链接地址:https://www.qianduange.cn//article/15294.html
标签
评论
还可以输入200
共0条数据,当前/页
发布的文章

安装Nodejs后,npm无法使用

2024-11-30 11:11:38

大家推荐的文章
会员中心 联系我 留言建议 回顶部
复制成功!