diff --git a/packages/@vue/cli/lib/util/ProjectPackageManager.js b/packages/@vue/cli/lib/util/ProjectPackageManager.js index 0cc7588be5..2531cf3457 100644 --- a/packages/@vue/cli/lib/util/ProjectPackageManager.js +++ b/packages/@vue/cli/lib/util/ProjectPackageManager.js @@ -134,6 +134,10 @@ class PackageManager { this.needsNpmInstallFix = true } + + if (semver.gte(npmVersion, '7.0.0')) { + this.needsPeerDepsFix = true + } } if (!SUPPORTED_PACKAGE_MANAGERS.includes(this.bin)) { @@ -374,7 +378,7 @@ class PackageManager { return } - return await this.runCommand('install') + return await this.runCommand('install', this.needsPeerDepsFix ? ['--legacy-peer-deps'] : []) } async add (packageName, { @@ -390,6 +394,10 @@ class PackageManager { } } + if (this.needsPeerDepsFix) { + args.push('--legacy-peer-deps') + } + return await this.runCommand('add', [packageName, ...args]) }