Skip to content

[BUG] regression - npm_config_prefix no longer works with global npx #5268

@rwoll

Description

@rwoll

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

Using the npm_config_prefix results in a no such file or directory error when attempting to run a command via npx globally on npm@8.16.0. The same command used to work on npm@8.15.1.

Expected Behavior

Global npx command works in conjunction with npm_config_prefix outside of a project/workspace.

Steps To Reproduce

$ mkdir repro
$ cd repro
$ npm i -g npm@8.15.1
$ npm_config_prefix=/tmp/.foo npx serve@latest --help
# observe `serve` CLI is executed successfully and the help message is printed

Now, upgrade npm and repeat:

$ npm i -g npm@8.16.0
$ npm_config_prefix=/tmp/.foo npx serve@latest --help
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path /private/tmp/.foo/lib
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, lstat '/private/tmp/.foo/lib'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /…/.npm/_logs/2022-08-05T21_22_57_389Z-debug-0.log

💥 Observe npx errors and complains This is related to npm not being able to find a file..

Environment

  • npm:
    • GOOD: 8.15.1
    • BAD: 8.16.0
  • Node.js: v16.14.0
  • OS Name: macOS, Ubuntu 22
  • System Model Name: M1 Macbook Pro, GitHub Action Runner
  • npm config:
$ npm config ls
; node bin location = /Users/…/.nvm/versions/node/v16.14.0/bin/node
; node version = v16.14.0
; npm local prefix = /Users/…/Desktop/repro
; npm version = 8.16.0
; cwd = /Users/…/Desktop/repro
; HOME = /Users/…
; Run `npm config ls -l` to show all defaults.

Additionally, npm_config_prefix is set when running npx command.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingPriority 2secondary 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