Skip to content

[BUG] npm config set ignores values starting with "-" #5131

@Ansile

Description

@Ansile

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 npm config set is provided with value that starts with "-", it ignores this value and sets an empty string instead.
This is a serious issue for us, as some tokens can generate starting with "-".

Bug case:

y-golubev:~ y.golubev$ npm -v
8.5.5

y-golubev:~ y.golubev$ npm config set "foo" "-bar"

y-golubev:~ y.golubev$ npm config list
...
foo = ""

Expected Behavior

Instead, it should just set the provided value.

Expected:

y-golubev:~ y.golubev$ npm -v
8.5.5

y-golubev:~ y.golubev$ npm config set "foo" "-bar"

y-golubev:~ y.golubev$ npm config list
...
foo = "-bar" 

That's the way it works with all other values.

Steps To Reproduce

Works the same with basically any npm version.

Run:

npm config set "foo" "-bar"
npm config list | grep foo

Outputs foo = ""

Environment

  • npm: 8.5.5
  • Node.js: v17.8.0
  • OS Name: macOS 10.14.6
  • System Model Name: Macbook Pro

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 8.xwork is associated with a specific npm 8 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions