1. 使用nvm安装node时候报错
报错内容
Get "https://npm.taobao.org/mirrors/node/latest/SHASUMS256.txt": tls: failed to verify certificate: x509: certificate has expired or is not yet valid:
报错原因
淘宝镜像地址的证书过期了
解决
找到nvm
安装的根目录下的settings.txt
文件
node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/
修改成
node_mirror: https://npmmirror.com/mirrors/node/
npm_mirror: https://npmmirror.com/mirrors/npm/
2. npm安装项目依赖报错
报错内容
request to https://registry.npm.taobao.org/semver/download/semver-5.7.1.tgz failed, reason: certificate has expired
报错原因
淘宝镜像地址的证书过期了
解决
配置新的淘宝镜像地址:
npm config set https://registry.npmmirror.com
或者安装依赖的时候指定
npm install --registry=https://registry.npmmirror.com
如果设置新的淘宝镜像地址仍然无法解决,可以删除项目中的package-lock.json
文件再次尝试,因为里面也会指定依赖下载地址,存在使用过期的淘宝镜像地址仍会报错
3. yarn install安装项目依赖报错
报错内容
error Couldn't find package "fsevents@~2.3.2" required by "chokidar@^3.4.2" on the "npm" registry
报错原因
找不到包fsevents@~2.3.2
解决
删除项目中的yarn.lock
和package-lock.json
,然后再次执行
yarn install#也可以使用淘宝镜像
yarn install --registry=https://registry.npmmirror.com