Skip to content

[BUG] Inconsistency between calls to npm on node.js 16.x #3871

Closed
@nassau-t

Description

@nassau-t

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

A call to npm outdated, if there are outdated packages, throws an exit code status of 1

C:\temp>node
Welcome to Node.js v16.11.0.
Type ".help" for more information.
> require('child_process').execSync('npm outdated -g --depth=0')
Uncaught Error: Command failed: npm outdated -g --depth=0
    at checkExecSyncError (node:child_process:826:11)
    at Object.execSync (node:child_process:900:15) {
  status: 1,
  signal: null,
  output: [
    null,
    <Buffer 50 61 63 6b 61 67 65 20 20 20 20 20 20 20 20 20 20 20 20 20 43 75 72 72 65 6e 74 20 20 20 57 61 6e 74 65 64 20 20 20 4c 61 74 65 73 74 20 20 4c 6f 63 ... 216 more bytes>,
    <Buffer >
  ],
  pid: 14996,
  stdout: <Buffer 50 61 63 6b 61 67 65 20 20 20 20 20 20 20 20 20 20 20 20 20 43 75 72 72 65 6e 74 20 20 20 57 61 6e 74 65 64 20 20 20 4c 61 74 65 73 74 20 20 4c 6f 63 ... 216 more bytes>,
  stderr: <Buffer >
}

C:\temp>npm -v
8.0.0

Expected Behavior

It was working like this in the the node.js 16.x branch until 16.11.

C:\temp>node
Welcome to Node.js v16.10.0.
Type ".help" for more information.
> require('child_process').execSync('npm outdated -g --depth=0')
<Buffer 50 61 63 6b 61 67 65 20 20 20 20 20 20 20 20 20 20 20 20 20 43 75 72 72 65 6e 74 20 20 20 57 61 6e 74 65 64 20 20 20 4c 61 74 65 73 74 20 20 4c 6f 63 ... 216 more bytes>

C:\temp>npm -v
7.24.0

Steps To Reproduce

  1. In this environment...
    Windows 10 pro x64. Node.js v16.11.0 (with included npm v8.0.0)

  2. With this config...
    A system with global outdated packages.

  3. Run '...'
    require('child_process').execSync('npm outdated -g --depth=0')

  4. See error...
    Throws a exit status code of 1

Environment

  • OS: Windows 10 Pro x64
  • Node: 16.11.0
  • npm: 8.0.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 7.xwork is associated with a specific npm 7 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions