我透過查看Vue CLI原始碼找到了解決方案。如果您使用登錄機(jī)碼參數(shù)執(zhí)行 create 指令,或者可以設(shè)定環(huán)境變數(shù) VUE_CLI_TEST 以避免出現(xiàn)該提示。由於我不知道設(shè)定該變數(shù)還有什麼其他影響,因此我使用註冊表命令運(yùn)行。
這是src中的程式碼,shouldUseTaobao
是負(fù)責(zé)提示的函數(shù):
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 } }