Vue3 CLI 不断询问互联网连接速度慢的问题
P粉127901279
P粉127901279 2023-09-04 13:16:33
[Vue.js讨论组]
<p>在E2E测试过程中,我通过Vue CLI自动安装Vue3,确切的命令是:</p> <pre class="brush:php;toolbar:false;">npx --yes @vue/cli create vue3 --packageManager npm -n -i '{&quot;useConfigFiles&quot;:true,&quot;plugins&quot;:{&quot;@vue/cli-plugin-babel&quot;:{},&quot;@vue/cli-plugin-typescript&quot;:{&quot;classComponent&quot;:false,&quot;useTsWithBabel&quot;:true},&quot;@vue/cli-plugin-pwa&quot;:{},&quot;@vue/cli-plugin-router&quot;:{&quot;historyMode&quot;:true},&quot;@vue/cli-plugin-vuex&quot;:{},&quot;@vue/cli-plugin-eslint&quot;:{&quot;config&quot;:&quot;prettier&quot;,&quot;lintOn&quot;:[&quot;save&quot;]}},&quot;vueVersion&quot;:&quot;3&quot;}'</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
      }
    }
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号