npm / npm/cli

[BUG] Version 7.x Nerfs JSON Output for Install Command

Open
#2,773 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Priority 2 Release 7.x
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

Summary:

npm 7.x seriously nerfed the usefulness of the --json flag when paired with the install command. (It may have done so with other commands as well; I've only tested install.)

I do realize that --json is marked experimental for all commands other than ls and search, but this is a MASSIVE regression in usefulness. I can understand changing the structure of the returned JSON, etc. while the feature is experimental, but nuking all of the details and returning only the bare minimum summary information must be an inadvertent change, right?

This makes npm exceptionally difficult to integrate with build tools and scripts. I've rolled back from 7.x until this can be addressed. Thanks!

Current Behavior:

Using npm 7.5.3 run this command: npm install jquery --json

The output produced is:

{
  "added": 1,
  "removed": 0,
  "changed": 0,
  "audited": 2,
  "funding": 0,
  "audit": {
    "vulnerabilities": {
      "info": 0,
      "low": 0,
      "moderate": 0,
      "high": 0,
      "critical": 0,
      "total": 0
    },
    "dependencies": {
      "prod": 2,
      "dev": 0,
      "optional": 0,
      "peer": 0,
      "peerOptional": 0,
      "total": 1
    }
  }
}
Expected Behavior:

Here's what npm < 7 spits out for the same command.

Notice the detail in added—we can see what was done, not just how many things were done.

{
  "added": [
    {
      "action": "add",
      "name": "jquery",
      "version": "3.5.1",
      "path": "/Users/bdkjones/Desktop/untitled folder/node_modules/jquery"
    }
  ],
  "removed": [],
  "updated": [],
  "moved": [],
  "failed": [],
  "warnings": [],
  "audit": {
    "actions": [],
    "advisories": {},
    "muted": [],
    "metadata": {
      "vulnerabilities": {
        "info": 0,
        "low": 0,
        "moderate": 0,
        "high": 0,
        "critical": 0
      },
      "dependencies": 1,
      "devDependencies": 0,
      "optionalDependencies": 0,
      "totalDependencies": 1
    }
  },
  "funding": "",
  "elapsed": 745
}
Steps To Reproduce:
  1. Just run npm install [any package name] --json on npm 7.x and compare the output to npm 6.x and below.
Environment:
  • OS: macOS 11.2.1
  • Node: 14.15.1 and 15.10.0 (I tested both)
  • npm: 7.5.3

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing npm install jquery --json with npm 7.x and compare its output with npm 6.x, using the command and version details in the issue. Done means restoring the detailed install result information, including item-level added, removed, updated, moved, failed, and warning data in JSON output.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.