diff --git a/packages/@vue/cli/lib/util/shouldUseTaobao.js b/packages/@vue/cli/lib/util/shouldUseTaobao.js index 8384ad00d6..011c362baf 100644 --- a/packages/@vue/cli/lib/util/shouldUseTaobao.js +++ b/packages/@vue/cli/lib/util/shouldUseTaobao.js @@ -38,9 +38,19 @@ module.exports = async function shouldUseTaobao (command) { return val } - const userCurrent = (await execa(command, ['config', 'get', 'registry'])).stdout - const defaultRegistry = registries[command] + let userCurrent + try { + userCurrent = (await execa(command, ['config', 'get', 'registry'])).stdout + } catch (registryError) { + try { + // Yarn 2 uses `npmRegistryServer` instead of `registry` + userCurrent = (await execa(command, ['config', 'get', 'npmRegistryServer'])).stdout + } catch (npmRegistryServerError) { + return save(false) + } + } + const defaultRegistry = registries[command] if (removeSlash(userCurrent) !== removeSlash(defaultRegistry)) { // user has configured custom registry, respect that return save(false)