Skip to content

Commit 59d84c5

Browse files
authored
disable corepack auto pin feature when executing npm view (microsoft#210601)
1 parent e30f27d commit 59d84c5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

extensions/npm/src/features/packageJSONContribution.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,13 @@ export class PackageJSONContribution implements IJSONContribution {
287287
return new Promise((resolve, _reject) => {
288288
const args = ['view', '--json', '--', pack, 'description', 'dist-tags.latest', 'homepage', 'version', 'time'];
289289
const cwd = resource && resource.scheme === 'file' ? dirname(resource.fsPath) : undefined;
290-
cp.execFile(npmCommandPath, args, { cwd }, (error, stdout) => {
290+
291+
// corepack npm wrapper would automatically update package.json. disable that behavior.
292+
// COREPACK_ENABLE_AUTO_PIN disables the package.json overwrite, and
293+
// COREPACK_ENABLE_PROJECT_SPEC makes the npm view command succeed
294+
// even if packageManager specified a package manager other than npm.
295+
const env = { COREPACK_ENABLE_AUTO_PIN: "0", COREPACK_ENABLE_PROJECT_SPEC: "0" };
296+
cp.execFile(npmCommandPath, args, { cwd, env }, (error, stdout) => {
291297
if (!error) {
292298
try {
293299
const content = JSON.parse(stdout);

0 commit comments

Comments
 (0)