Skip to content

Commit

Permalink
Merge pull request #21947 from storybookjs/valentin/fix-npm-ls-unexpe…
Browse files Browse the repository at this point in the history
…cted-error-thrown

Add platform-specific null piping for stderr for npm list command
  • Loading branch information
ndelangen authored Apr 5, 2023
2 parents 773fdab + 701638e commit 29ea8a8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion code/lib/cli/src/js-package-manager/NPMProxy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sort from 'semver/functions/sort';
import { platform } from 'os';
import { JsPackageManager } from './JsPackageManager';
import type { PackageJson } from './PackageJson';
import type { InstallationMetadata, PackageMetadata } from './types';
Expand Down Expand Up @@ -51,7 +52,8 @@ export class NPMProxy extends JsPackageManager {
}

public findInstallations() {
const commandResult = this.executeCommand('npm', ['ls', '--json', '--depth=99']);
const pipeToNull = platform() === 'win32' ? '2>NUL' : '2>/dev/null';
const commandResult = this.executeCommand('npm', ['ls', '--json', '--depth=99', pipeToNull]);

try {
const parsedOutput = JSON.parse(commandResult);
Expand Down

0 comments on commit 29ea8a8

Please sign in to comment.