uniapp vue-cli 报错 Failed to get response from https://registry.npm.taobao.org/binary-mirror-config

vue-cli创建vue2 uni-app项目步骤,及报错解决方案

1、安装vue-cli

 npm install -g @vue/cli@4

官方提供命令是 npm install -g @vue/cli安装的是版本5,但uni-cli仅支持vue-cli 4.x版本,启动会报错

2、使用vue-cli构建项目

vue create -p dcloudio/uni-preset-vue my-project

这个步骤会报如下错误:

 ERROR  Failed to get response from https://registry.npm.taobao.org/binary-mirror-config
yarn install v1.22.22
info No lockfile found.
[1/4] 🔍  Resolving packages...
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error Error: certificate has expired
   at TLSSocket.onConnectSecure (_tls_wrap.js:1515:34)
   at TLSSocket.emit (events.js:400:28)
   at TLSSocket._finishInit (_tls_wrap.js:937:8)
   at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:709:12)
ERROR  command failed: yarn 

这是因为淘宝镜像地址https://registry.npm.taobao.org已经停用,需要更换为https://registry.npmmirror.com而vue-cli4.x目前还是使用的旧地址,我们可以通过如下方式解决:

  • 执行命令npm root -g 查看全局安装目录
  • 进入该目录,找到vue-cli的镜像配置文件@vue/cli/lib/util/registries.js,将文件内容替换为
const registries = {
 npm: 'https://registry.npmjs.org',
 yarn: 'https://registry.yarnpkg.com',
 taobao: 'https://registry.npmmirror.com', // 主要是这段
 pnpm: 'https://registry.npmjs.org'
}

module.exports = registries
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值