[BUG] npm config silently ignores values that start with a dash #2250
Labels
Bug
thing that needs fixing
Needs Triage
needs review for next steps
Release 7.x
work is associated with a specific npm 7 release
Current Behavior:
Given a config command like this:
npm config set '//gitlab.vendor.com/api/v4/packages/npm/:_authToken' "-iF_9eLYJkB2a3simuB1"
It silently fails to set the configuration key. The command returns
0
while the key turns out to be empty in.npmrc
.My suspect is that
-iF_9eLYJkB2a3simuB1
ends up being considered a command line option instead of a positional argument. This is somewhat confirmed by explicitly using--
to tellnpm
not to search for more options, which brings the expected behaviour back. Another workaround is to use the (apparently undocumented) syntax:npm config set "//gitlab.vendor.com/api/v4/packages/npm/:_authToken=-iF_9eLYJkB2a3simuB1"
Still, IMO, silently ignoring the value is not the correct behaviour. We should probably at least complain about an invalid option instead.
Expected Behavior:
Either the configuration key is correctly assigned the given value, or the command fails due to an invalid
-iF_9eLYJkB2a3simuB1
option.Steps To Reproduce:
ex. steps to reproduce the behavior:
npm
v6, v7, or latestnpm config set '//gitlab.vendor.com/api/v4/packages/npm/:_authToken' "-iF_9eLYJkB2a3simuB1"
.npmrc
content for the above key and verify it's empty://gitlab.vendor.com/api/v4/packages/npm/:_authToken=
The text was updated successfully, but these errors were encountered: