Vue3 CLI keeps asking about slow internet connection
P粉127901279
P粉127901279 2023-09-04 13:16:33
0
1
758
<p>During the E2E testing process, I automatically installed Vue3 through the Vue CLI. The exact command is: </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>The problem is that during this process, this problem keeps appearing: </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>The build failed because it is waiting for input. How can I cancel this prompt? </p>
P粉127901279
P粉127901279

reply all(1)
P粉412533525

I found the solution by looking at the Vue CLI source code. If you run the create command with registry parameters, you can set the environment variable VUE_CLI_TEST to avoid this prompt. Since I don't know what other effects setting this variable has, I ran it using a registry command. This is the code in src, shouldUseTaobao is the function responsible for the prompt:

    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
      }
    }
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template