Skip to content

[BUG] npm config does not allow path types to use ${ENVIRONMENT_VARIABLE} syntax. #5267

@alasdairhurst

Description

@alasdairhurst

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

I'm trying to configure a project using the command line by setting a custom registry and CA file. The project will be built in a docker container, so all configuration should be configured relative to the project, and nothing from the host should be referenced.

Since npm automatically turns the relative paths into absolute paths when setting cafile, let's try an use an environment variable as documented here: https://docs.npmjs.com/cli/v7/configuring-npm/npmrc

npm config set cafile='\${PWD}/cafile.crt' --location=project

This results in the bug:

cafile=/absolute/path/to/project/${PWD}/cafile.crt

This is also an issue without setting location

Expected Behavior

I expect

npm config set cafile='\${PWD}/cafile.crt'

To write:

cafile=${PWD}/cafile.crt

Steps To Reproduce

  1. run npm config set cafile='\${PWD}/cafile.crt'
  2. see that unexpected data is written to .npmrc

Environment

  • npm: 8.16.0
  • Node.js: 16.14.2
  • OS Name: MacOS Big Sur
  • System Model Name:
  • npm config:
; copy and paste output from `npm config ls` here

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingPriority 1high priority issueRelease 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