cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] Colon in working directory break package resolution

Open arseniybanayev opened this issue 2 years ago • 3 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

This issue exists in the latest npm version

  • [X] I am using the latest npm

Current Behavior

If I am in a directory that contains a : in the full name (e.g., /home/username/my:weird:folder):

  1. npx {package} does not resolve {package} successfully, including if ./node_modules/.bin/{package} exists and can be run explicitly as ./node_modules/.bin/{script}.
  2. npm run {script} does not resolve {package} successfully if {script} is defined in package.json using {package}, including if ./node_modules/.bin/{package} exists and can be run explicitly as ./node_modules/.bin/{script}.

Expected Behavior

I expect the resolutions in 1 and 2 above to work.

Steps To Reproduce

No response

Environment

No response

arseniybanayev avatar Jun 24 '23 15:06 arseniybanayev

The bug is still present in 10.9.2. It took me embarrassingly long to figure out what the issue was 😅

FelixMo42 avatar Jun 11 '25 20:06 FelixMo42

Clearly this is not very high priority, since it's been 2 years since the first report, but I'll try to put together a patch to resolve the issue

FelixMo42 avatar Jun 11 '25 21:06 FelixMo42

The issue is that PATH on macos and linux uses colons as the deliminator. The way to make this work would be to alias the bin without a colon name in the path and add the alias to PATH. But I'm guessing the core maintainers would not be interested in that (it sounds like a pain to manage). Instead I'm going to add an error message (or maybe a warning might be better?) and call it a day

FelixMo42 avatar Jun 12 '25 07:06 FelixMo42