From 30f72420e273df5efc2829b9f10064a1bdeadad0 Mon Sep 17 00:00:00 2001 From: Haoqun Jiang Date: Fri, 8 Nov 2019 22:03:37 +0800 Subject: [PATCH] fix: `vue add` should not crash when executed under Yarn PnP TODO: should fix `loadModule` in PnP environment --- packages/@vue/cli/lib/add.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@vue/cli/lib/add.js b/packages/@vue/cli/lib/add.js index a2a3368013..d00afb2e12 100644 --- a/packages/@vue/cli/lib/add.js +++ b/packages/@vue/cli/lib/add.js @@ -20,7 +20,7 @@ async function add (pluginName, options = {}, context = process.cwd()) { // for `vue add` command in 3.x projects const servicePkg = loadModule('@vue/cli-service/package.json', context) - if (semver.satisfies(servicePkg.version, '3.x')) { + if (servicePkg && semver.satisfies(servicePkg.version, '3.x')) { // special internal "plugins" if (/^(@vue\/)?router$/.test(pluginName)) { return addRouter(context)