Skip to content

[BUG] npx fails to run without empty lib directory #6351

@knpwrs

Description

@knpwrs

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 node is installed with hermit, npx does not work:

npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path /Users/knpwrs/Downloads/hermit-npx-bug/.hermit/node/lib
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, lstat '/Users/knpwrs/Downloads/hermit-npx-bug/.hermit/node/lib'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

Creating the .hermit/node/lib directory via mkdir -p .hermit/node/lib appears to fix this issue, even though the directory doesn't contain anything.

See https://github.com/cashapp/hermit-packages/issues/309, the hermit maintainers believe this is a bug with npx.

Expected Behavior

npx should work without needing an empty lib directory to exist.

Steps To Reproduce

  1. Install hermit
  2. mkdir hermit-npx-bug && cd hermit-npx-bug
  3. hermit init
  4. . ./bin/activate-hermit
  5. hermit install node
  6. which npx (this will verify the hermit-installed npx is being used)
  7. npx rimraf --help (this will fail)
  8. mkdir -p .hermit/node/lib
  9. npx rimraf --help (this works now!)

Environment

  • npm: 9.2.0
  • Node.js: 19.4.0
  • OS Name: macOS Ventura 13.1
  • System Model Name: Macbook Pro
  • npm config:
; "user" config from /Users/knpwrs/.npmrc

//registry.npmjs.org/:_authToken = (protected)

; "env" config from environment

cache = "/Users/knpwrs/Downloads/hermit-npx-bug/.hermit/node/cache"
prefix = "/Users/knpwrs/Downloads/hermit-npx-bug/.hermit/node"

; node bin location = /Users/knpwrs/Library/Caches/hermit/pkg/node-19.9.0/bin/node
; node version = v19.9.0
; npm local prefix = /Users/knpwrs/Downloads
; npm version = 9.6.3
; cwd = /Users/knpwrs/Downloads/hermit-npx-bug
; HOME = /Users/knpwrs
; Run `npm config ls -l` to show all defaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions