P粉4125335252023-09-05 10:01:59
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 } }