还是那句话:多试试, npm 或者 yarn 安装依赖都行。
最后实在不行:下载我最新的依赖包: 里面有win和mac的版本
链接:https://pan.baidu.com/s/1NHFPCJm5cLlFAMe5rMRiWQ?pwd=tvt1
提取码:tvt1
=============================================================
由于有时候网络的原因,会导致 npm 、yarn 下载遇到各种各样的问题。而且我们正好会使用科学上网方法。那么我们就可以为 npm 、yarn 设置代理。让它们通过代理的方式的得到更优的下载网络,从而解决疑难杂症。
设置proxy:
yarn config set https-proxy http://127.0.0.1:7890
yarn config set proxy http://127.0.0.1:7890
npm config set proxy http://127.0.0.1:7890
npm config set https-proxy http://127.0.0.1:7890
取消代理:
yarn config delete proxy
yarn config delete https-proxy
npm config delete proxy
npm config delete https-proxy
修改源:
//淘宝
yarn config set registry http://registry.npm.taobao.org/
//淘宝2
yarn config set registry https://registry.npmmirror.com/
//官方
yarn config set registry https://registry.yarnpkg.com
//淘宝
npm config set registry http://registry.npm.taobao.org/
//淘宝2
npm config set registry https://registry.npmmirror.com/
//官方
npm config set registry https://registry.npmjs.org/
查看当前设置的源:
// yarn 默认:https://registry.yarnpkg.com
yarn config get registry
npm get registry
例如在TvT.js项目中遇到:
ERR! network request to https://registry.npmjs.org/@alienkitty%2fspace.js failed, reason: connect ETIMEDOUT 104.16.27.34:443
或者
ERR! No versions available for @alienkitty/space.js
npm config set registry https://registry.npmmirror.com/
或者
error Received malformed response from registry for "@alienkitty%2fspace.js". The registry may be down.
需要使用:
官方的源,且使用翻墙proxy代理来安装依赖
对了,如还报错 ,请删除项目更目录下的 yarn.lock 之类的文件
npm/pnpm/yarn切换源
国内镜像
提供商 搜索地址 registry地址
淘宝 https://npmmirror.com/ https://registry.npmmirror.com
腾讯云 http://mirrors.cloud.tencent.com/npm/
华为云 https://mirrors.huaweicloud.com/repository/npm
浙江大学 http://mirrors.zju.edu.cn/npm/
南京邮电 https://mirrors.njupt.edu.cn/nexus/repository/npm/
npm
查看源
npm get registry
npm config get registry
临时修改
npm --registry https://registry.npmmirror.com install any-touch
永久修改
npm config set registry https://registry.npmmirror.com
还原
npm config set registry https://registry.npmjs.org
NRM
安装 nrm
npm install -g nrm
列出当前可用的所有镜像源
nrm ls
使用淘宝镜像源
nrm use taobao
测试访问速度
nrm test taobao
pnpm
查看源
pnpm get registry
pnpm config get registry
临时修改
pnpm --registry https://registry.npmmirror.com install any-touch
永久修改
pnpm config set registry https://registry.npmmirror.com
还原
pnpm config set registry https://registry.npmjs.org
yarn
查看源
yarn config get registry
临时修改
yarn add any-touch@latest --registry=https://registry.npmjs.org/
永久修改
yarn config set registry https://registry.npmmirror.com/
还原
yarn config set registry https://registry.yarnpkg.com
YRM
安装 yrm
npm install -g yrm
列出当前可用的所有镜像源
yrm ls
使用淘宝镜像源
yrm use taobao
测试访问速度
yrm test taobao
多试试, npm 或者 yarn 安装依赖都行。
最后实在不行:下载我最新的依赖包: 里面有win和mac的版本
链接:https://pan.baidu.com/s/1NHFPCJm5cLlFAMe5rMRiWQ?pwd=tvt1
提取码:tvt1