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] npm set does not respect -g flag in 7.20.0 onwards #3572

Closed
1 task done
billyjanitsch opened this issue Jul 23, 2021 · 1 comment · Fixed by #3684
Closed
1 task done

[BUG] npm set does not respect -g flag in 7.20.0 onwards #3572

billyjanitsch opened this issue Jul 23, 2021 · 1 comment · Fixed by #3684
Assignees
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release

Comments

@billyjanitsch
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

npm set -g foo bar

In npm < 7.20.0, this writes foo=bar to the global npm config file (/usr/local/etc/npmrc).

In npm >= 7.20.0, the -g flag is not respected and foo=bar is written to the user npm config file (~/.npmrc).

Expected Behavior

The -g flag should result in a modification to the global config, not the user config.

Steps To Reproduce

  1. Run npm set -g foo bar.
  2. Run npm get.
  3. Note that foo has been set in the user config rather than the global config.

Environment

  • OS: macOS 10.15.7
  • Node: 14.17.3
  • npm: 7.20.0
@billyjanitsch billyjanitsch added Bug thing that needs fixing Needs Triage needs review for next steps Release 7.x work is associated with a specific npm 7 release labels Jul 23, 2021
@billyjanitsch
Copy link
Author

This bug was introduced in #3471.

There's some logic there that's supposed to set the value of the new -L flag based on -g, but it appears to not be working correctly.

That PR seems to have updated all of the tests for --global to instead use --location=global, so they didn't catch this regression. Perhaps at least one test should be added back to verify that --global continues to work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Release 7.x work is associated with a specific npm 7 release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants