fix: disable corepack strict mode

This commit is contained in:
2026-03-09 16:33:29 +02:00
parent 96530745b3
commit 27ba113e8e
2 changed files with 16 additions and 0 deletions

View File

@@ -48,6 +48,11 @@ func buildCmd(t tasks.Task, cwd string, env []string) (*exec.Cmd, func(), error)
case "npm":
npmExe := tasks.ResolvePackageManagerExecutable(cwd, "npm")
// Disable corepack strict version enforcement so that a
// packageManager version mismatch doesn't block execution.
// VS Code doesn't go through corepack, so this keeps parity.
env = appendEnvIfMissing(env, "COREPACK_ENABLE_STRICT", "0")
// Support either:
// - Command/Script = npm subcommand or script name
// - Command empty with first arg being subcommand/script

View File

@@ -370,6 +370,17 @@ func mergeEnv(base []string, extra map[string]string) []string {
return out
}
// appendEnvIfMissing adds key=value to env only if key is not already set.
func appendEnvIfMissing(env []string, key, value string) []string {
prefix := key + "="
for _, kv := range env {
if strings.HasPrefix(kv, prefix) {
return env
}
}
return append(env, prefix+value)
}
func defaultShell() (exe string, args []string) {
if runtime.GOOS == "windows" {
return "cmd.exe", []string{"/C"}