Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Inconsistent --silent for npm install #4877

Closed
2 tasks done
Ninroot opened this issue May 10, 2022 · 2 comments
Closed
2 tasks done

[BUG] Inconsistent --silent for npm install #4877

Ninroot opened this issue May 10, 2022 · 2 comments
Labels
config:display Issues dealing with display of data to terminal semver:major backwards-incompatible breaking changes

Comments

@Ninroot
Copy link

Ninroot commented May 10, 2022

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

When running npm install with json and silent options the result are inconsistent.

json + silent options when the package does not exist removes the logs such as npm ERR! code E404 + prints the JSON as expected 👍

npm install --json --silent shouldnotexistforthatexample      
{
  "error": {
    "code": "E404",
    "summary": "Not Found - GET https://registry.npmjs.org/shouldnotexistforthatexample - Not found",
    "detail": "\n 'shouldnotexistforthatexample@*' is not in this registry.\n\nNote that you can also install from a\ntarball, folder, http url, or git url."
  }
}

json options when the package exists prints the JSON as expected 👍

npm install --json chalk         
{
  "added": 0,
  "removed": 0,
  "changed": 0,
  "audited": 954,
  "funding": 186,
  "audit": {
    "vulnerabilities": {
      "info": 0,
      "low": 0,
      "moderate": 1,
      "high": 1,
      "critical": 0,
      "total": 2
    },
    "dependencies": {
      "prod": 199,
      "dev": 751,
      "optional": 5,
      "peer": 48,
      "peerOptional": 0,
      "total": 953
    }
  }
}

json + silent options when the package exists removes the JSON 👎

$ npm install --json --silent chalk
# no output

Expected Behavior

npm install --silent --json <existingPackage> should silent the log and leave the json result.

Steps To Reproduce

Default config

Environment

  • npm: 8.9.0
  • Node.js: v18.1.0
  • OS Name: 21.4.0 Darwin Kernel Version 21.4.0 RELEASE_ARM64_T6000 arm64
  • System Model Name: MacBook Pro (14-inch, 2021)
  • npm config:
; "user" config from /Users/arnauddebec/.npmrc

//registry.npmjs.org/:_authToken = (protected) 

; node bin location = /Users/arnauddebec/.nvm/versions/node/v18.1.0/bin/node
; node version = v18.1.0
; npm local prefix = /Users/arnauddebec/Dev/nacre-test/importhellonacre/node_modules/chalk
; npm version = 8.9.0
; cwd = /Users/arnauddebec/Dev/nacre-test/importhellonacre/node_modules/chalk
; HOME = /Users/arnauddebec
; Run `npm config ls -l` to show all defaults.
@Ninroot Ninroot added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels May 10, 2022
@lukekarrys lukekarrys added config:display Issues dealing with display of data to terminal semver:major backwards-incompatible breaking changes and removed Release 8.x work is associated with a specific npm 8 release Needs Triage needs review for next steps labels May 11, 2024
@lukekarrys
Copy link
Contributor

lukekarrys commented May 14, 2024

--silent only really work to silence log messages. But some commands in npm also check npm.silent in order to hide ouput.

npm should imo (in a future breaking change):

  • make --silent always hide all output and logging in display.js so it is applied consistently to all commands
  • go through commands and remove checks for npm.silent for output
  • maybe add a new --loglevel=silent that is NOT an alias for --silent for only hiding all logs

@lukekarrys lukekarrys removed the Bug thing that needs fixing label May 14, 2024
@lukekarrys
Copy link
Contributor

I'm going to close this and track in our v11 roadmap issue: npm/statusboard#488 Semver major changes in the issue tracker tend to get lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config:display Issues dealing with display of data to terminal semver:major backwards-incompatible breaking changes
Projects
None yet
Development

No branches or pull requests

2 participants