Skip to content

Using npm_config__auth environtment variable in v8 to authorize private repository #3985

@manuel-buchner

Description

@manuel-buchner

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

I want to add dist-tags using npm dist-tag add ... in a private repository.

As of NPM v6.14.15 it was possible, to authorize the user using the npm_config__auth environment variable.
I think that was done by this line: https://github.com/npm/cli/blob/v6.14.15/node_modules/npm-registry-fetch/auth.js#L22

When upgrading to v8.1.0 the environment variable will be ignored and only the repo based _auth key is used
Like this line: https://github.com/npm/cli/blob/v8.1.0/node_modules/npm-registry-fetch/auth.js#L81

Is it on purpose to ignore _auth for private repos and only use repo based e.g. //artifactory.company.com/artifactory/api/npm/npm/:_auth key?
Unfortunately i cannot provide this key using environment variable, because _ will be converted to -

However, when checking the user using npm whoami it resolves to the right user.
I think because of this: https://github.com/npm/cli/blob/release/v8.1.0/node_modules/%40npmcli/config/lib/index.js#L719

Expected Behavior

Be able to authorize private repository using npm_config__auth environment variable.

Steps To Reproduce

  1. Setup Private Repository
  2. Run node:16-alpine container
  3. Provide Private Repository with .npmrc file (but no _auth key)
  4. Provide _auth via npm_config__auth environment variable
  5. Run npm dist-tag add @scope/[email protected] feature

Environment

  • OS: Alpine 3.13.6
  • Node: 16.13.0
  • npm: 8.1.0

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