Skip to content

Commit e1eba09

Browse files
authored
fix: discard NODE_ENV when installing project dependencies (#6224)
Avoid empty `node_modules` when the user has set `NODE_ENV` to `production` in the shell environment. In the long run we should have a more comprehensive preflight check for execution environment though.
1 parent 51d82a5 commit e1eba09

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Diff for: packages/@vue/cli/lib/util/ProjectPackageManager.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -347,15 +347,25 @@ class PackageManager {
347347
}
348348

349349
async runCommand (command, args) {
350+
const prevNodeEnv = process.env.NODE_ENV
351+
// In the use case of Vue CLI, when installing dependencies,
352+
// the `NODE_ENV` environment variable does no good;
353+
// it only confuses users by skipping dev deps (when set to `production`).
354+
delete process.env.NODE_ENV
355+
350356
await this.setRegistryEnvs()
351-
return await executeCommand(
357+
await executeCommand(
352358
this.bin,
353359
[
354360
...PACKAGE_MANAGER_CONFIG[this.bin][command],
355361
...(args || [])
356362
],
357363
this.context
358364
)
365+
366+
if (prevNodeEnv) {
367+
process.env.NODE_ENV = prevNodeEnv
368+
}
359369
}
360370

361371
async install () {

0 commit comments

Comments
 (0)