[Vuejs]-Vue3 CLI keeps asking about slow internet connection

0👍

I found the solution by looking at the Vue CLI source code. If you run the create command with the registry parameter, or you can set the environment variable VUE_CLI_TEST to avoid that prompt. Since I don’t know what other implications setting the variable has, I run with the registry command.
Here’s the code from src, shouldUseTaobao is the function that is 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
      }
    }

Leave a comment