Vue3 CLI 不断询问互联网连接速度慢的问题
P粉127901279
P粉127901279 2023-09-04 13:16:33
0
1
596
<p>在E2E测试过程中,我通过Vue CLI自动安装Vue3,确切的命令是:</p> <pre class="brush:php;toolbar:false;">npx --yes @vue/cli create vue3 --packageManager npm -n -i '{"useConfigFiles":true,"plugins":{"@vue/cli-plugin-babel":{},"@vue/cli-plugin-typescript":{"classComponent":false,"useTsWithBabel":true},"@vue/cli-plugin-pwa":{},"@vue/cli-plugin-router":{"historyMode":true},"@vue/cli-plugin-vuex":{},"@vue/cli-plugin-eslint":{"config":"prettier","lintOn":["save"]}},"vueVersion":"3"}'</pre> <p>问题是,在这个过程中,这个问题不断出现:</p> <pre class="brush:php;toolbar:false;">? Your connection to the default yarn registry seems to be slow. Use https://registry.npmmirror.com for faster installation? (Y/n)</pre> <p>由于正在等待输入,因此构建失败。如何取消此提示?</p>
P粉127901279
P粉127901279

全部回复(1)
P粉412533525

我通过查看Vue CLI源代码找到了解决方案。如果您使用注册表参数运行 create 命令,或者可以设置环境变量 VUE_CLI_TEST 以避免出现该提示。由于我不知道设置该变量还有什么其他影响,因此我使用注册表命令运行。 这是src中的代码,shouldUseTaobao是负责提示的函数:

    const args = minimist(process.argv, {
      alias: {
        r: 'registry'
      }
    })

    let registry
    if (args.registry) {
      registry = args.registry
    } else if (!process.env.VUE_CLI_TEST && await shouldUseTaobao(this.bin)) {
      registry = registries.taobao
    } else {
      try {
        if (scope) {
          registry = (await execa(this.bin, ['config', 'get', scope + ':registry'])).stdout
        }
        if (!registry || registry === 'undefined') {
          registry = (await execa(this.bin, ['config', 'get', 'registry'])).stdout
        }
      } catch (e) {
        // Yarn 2 uses `npmRegistryServer` instead of `registry`
        registry = (await execa(this.bin, ['config', 'get', 'npmRegistryServer'])).stdout
      }
    }
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!