-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[DOCS] Setting an invalid loglevel does not terminate the execution of the change. #8082
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
Comments
One of the easy solution to this would be to reset log level at the command level. ~/workarea/rep $ cat .npmrc
loglevel=some-random-value
~/workarea/rep $ npm ls
~/workarea/rep $ npm ls -ddd
npm verbose cli /Users/milaninfy/.nvm/versions/node/v22.9.0/bin/node /Users/milaninfy/.nvm/versions/node/v22.9.0/bin/npm
npm info using [email protected]
npm info using [email protected]
npm silly config load:file:/Users/milaninfy/.nvm/versions/node/v22.9.0/lib/node_modules/npm/npmrc
npm silly config load:file:/Users/milaninfy/workarea/rep/.npmrc
npm silly config load:file:/Users/milaninfy/.npmrc
npm silly config load:file:/Users/milaninfy/.nvm/versions/node/v22.9.0/etc/npmrc
npm verbose title npm ls
npm verbose argv "ls" "--loglevel" "silly"
npm verbose logfile logs-max:10 dir:/Users/milaninfy/.npm/_logs/2025-02-04T17_42_28_612Z-
npm verbose logfile /Users/milaninfy/.npm/_logs/2025-02-04T17_42_28_612Z-debug-0.log
npm warn invalid config loglevel="some-random-value" set in /Users/milaninfy/workarea/rep/.npmrc
npm warn invalid config Must be one of: silent, error, warn, notice, http, info, verbose, silly
npm silly logfile start cleaning logs, removing 2 files
npm silly packumentCache heap:4345298944 maxSize:1086324736 maxEntrySize:543162368
npm silly logfile done cleaning log files
[email protected] /Users/milaninfy/workarea/rep
└── (empty)
npm verbose cwd /Users/milaninfy/workarea/rep
npm verbose os Darwin 24.3.0
npm verbose node v22.9.0
npm verbose npm v11.0.0
npm verbose exit 0
npm info ok |
This CLI Docs Enhancement request highlights a critical issue with npm's global configuration when an invalid log level argument is passed. The current behavior allows the invalid log level to be set without error, which effectively disables all npm logs, making even basic commands like npm -v unresponsive. The issue persists until the .npmrc file is manually deleted or edited. Proposed Fix
The CLI should validate the log-level argument and reject invalid values instead of silently applying them. |
These are already planned for the next semver major version of npm. As of now all we can do is warn, since rejecting them is a breaking change. Those warnings were added in npm 11.2.0. |
Is there an existing issue for this?
This is a CLI Docs Enhancement, not another kind of Docs Enhancement.
Description of Problem
When updating the loglevel of the npm global configuration, passing an invalid log level argument will not terminate the execution of the command itself. It will update the configuration with the invalid argument. This literally turns off any logs from the package manager. Node commands will work, but even checking the NPM version with "npm -v" will cease to work. Reinstalling will not fix this issue unless you explicitly delete the .npmrc file or edit it.
Potential Solution
The documentation of this potential issue should be mentioned with the steps to fix it or an error should be thrown when an incorrect log level is passed and when a subsequent NPM command executed.
Docs URL
https://docs.npmjs.com/cli/v8/using-npm/logging
The text was updated successfully, but these errors were encountered: