Skip to content

Commit 49db9c4

Browse files
committed
fix: npm 7 compat by turning on legacy-peer-deps flag (#5961)
1 parent d77fa6a commit 49db9c4

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

packages/@vue/cli/lib/util/ProjectPackageManager.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ class PackageManager {
134134

135135
this.needsNpmInstallFix = true
136136
}
137+
138+
if (semver.gte(npmVersion, '7.0.0')) {
139+
this.needsPeerDepsFix = true
140+
}
137141
}
138142

139143
if (!SUPPORTED_PACKAGE_MANAGERS.includes(this.bin)) {
@@ -374,7 +378,7 @@ class PackageManager {
374378
return
375379
}
376380

377-
return await this.runCommand('install')
381+
return await this.runCommand('install', this.needsPeerDepsFix ? ['--legacy-peer-deps'] : [])
378382
}
379383

380384
async add (packageName, {
@@ -390,6 +394,10 @@ class PackageManager {
390394
}
391395
}
392396

397+
if (this.needsPeerDepsFix) {
398+
args.push('--legacy-peer-deps')
399+
}
400+
393401
return await this.runCommand('add', [packageName, ...args])
394402
}
395403

0 commit comments

Comments
 (0)