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 and shilman committed Apr 6, 2023
1 parent d9f29a8 commit 3a16e05
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
@@ -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 3a16e05

Please sign in to comment.