Vue3 CLI 不斷詢問網路連線速度慢的問題
P粉127901279
P粉127901279 2023-09-04 13:16:33
0
1
597
<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},&clit; plugin-pwa":{},"@vue/cli-plugin-router":{"historyMode":true},"@vue/cli-plugin-vuex":{},"@vue/clicli] -plugin-eslint":{"config":"prettier","lintOn":["save"]}},"vueVersion":"3"]}},"vueVersion":"3" <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學習者快速成長!