Skip to content

Environment Variables left of = equals sign are not substituted when reading .npmrc #6679

@hanna-cirilla

Description

@hanna-cirilla

Any variables in .npmrc that occur left of the equals sign (i.e. in the key) are not substituted when reading the config. This behavior deviates from npm where they are substituted.

Our specific use case is dynamically configuring the registry authorization:

# .npmrc
//${REGISTRY}:_authToken=${TOKEN}

The value ${TOKEN} is set as expected but the key is used as-is.

pnpm version:

8.6.2

Code to reproduce the issue:

echo "\${FOO}=\${BAR}" > .npmrc
FOO=foo BAR=bar pnpm config list

Expected behavior:

Variable ${FOO} is substituted with value foo and used as key.

foo=bar

Actual behavior:

${FOO} is not substituted

${FOO}=bar

Additional information:

  • node -v prints: v20.3.0
  • Windows, macOS, or Linux?: Linux, tested in latest node container after installing pnpm via https://get.pnpm.io/install.sh
  • The issue appears to be a missing implementation of key replacement in readLocalConfig.ts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions