-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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] npm v 8.11.0 - writes to STDERR - "npm WARN config global --global
, --local
..." breaking our nightly build process.
#4989
Comments
This issue seems to be coming from
I also only see the issue on Windows. Edit: FWIW, the warning also triggers regardless of what is passed to npm - even explicitly passing |
This was fixed by #4982 and it's included in v8.12.1. You should bug the Node.js people to update the bundled npm there if it's not already done and cut a new version. Alternatively, you can update your npm instance until the issue is fixed in Node.js. |
Here's a workaround until Node.js v16.15.2 is released:
(Get-Content "${Env:ProgramFiles}\nodejs\npm.cmd") -replace '-g','-L=global' | Out-File -Encoding ascii "${Env:ProgramFiles}\nodejs\npm.cmd"
(Get-Content "${Env:ProgramFiles}\nodejs\npx.cmd") -replace '-g','-L=global' | Out-File -Encoding ascii "${Env:ProgramFiles}\nodejs\npx.cmd" The problem here happens because the version of npm in the Node.js installation directory is used to get the global prefix. After that, processing is handed over to the global version of npm, but by that point the warning has already been printed. The version of npm in the Node.js installation directory does not get updated when you run Edit: Looks like this is still needed for Node.js v16.16.0! |
Thank you @ehoogeveen-medweb I have forwarded this to our build-master so they can implement the fix. I appreciate your time in taking a look at this. |
Thanks |
I tried the workaround from @ehoogeveen-medweb and it removed the warning only for # PowerShell -> C:\Program Files\nodejs\npm.cmd
Get-Command npm # Git Bash -> C:\Program Files\nodejs\npm
which npm Therefore, to apply this workaround for # Git Bash
sed -i 's/-g/-L=global/g' "C:/Program Files/nodejs/npm"
sed -i 's/-g/-L=global/g' "C:/Program Files/nodejs/npx" |
Upgrading Node.js to the CURRENT version that included npm |
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
current version of npm (8.11.0, node 16.15.1) writes a warning to STDERR on every command, that is a warning about using deprecated options. The message is...
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
The message is written to STDERR regardless of whether or not the command run uses the --global or --local options. For example, the command...
npm -v
outputs the message, even though -v is the only option used, and writes to STDERR, even though it states it's purpose to be a warning, not an error, and the command still executes successfully.
The result for my organization is to break our nightly builds. Our builds need to monitor STDERR for REAL build errors, which also use STDERR to capture a variety of aberrant build conditions including security vulnerabilities that are reported back to the build pipeline via STDERR in a script that runs "npm audit" and analyzes the results.
Expected Behavior
IMHO, this warning should only be written if the deprecated options are used, and should be written to STDOUT since it is not an error, just a warning.
Steps To Reproduce
Environment
The text was updated successfully, but these errors were encountered: