npm / npm/cli

[BUG] npm fails to find hoisted bin files in monorepo when parent directory path contains a ':' character

Open
#9,910 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug cmd:run-script config:workspaces Needs Triage platform: linux
Dominant language
JavaScript
Stars
10.1k
Forks
4.7k
Avg merge
2d 2h
Merged PRs (30d)
19

Description

issue_9910_monorepo.tar.gz

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
This is not just a request to bump a dependency for a CVE
  • This is not solely a request to bump a dependency for a CVE
Current Behavior

If the parent directory path of a monorepo includes a ':' colon character, npm fails to find hoisted files in the monorepo node_modules/.bin directory.

Given a monorepo structure as follows:

parent:directory (note the colon in the name)
|- mono-repo
|- packages
|- @waitem
|- shared-types

with "workspaces": "packages/@waitem/*" defined in the top-level mono-repo directory
and a package.json file in packages/@waitem/shared-types which includes typescript as a dependency, and has a script: "build": "tsc" script

running npm install in the mono-repo directory works as expected, installing the hoisted packages in mono-repo/node_modules

However running npm -w @waitem/shared-types run build after npm install fails with the error message:

npm notice run @waitem/shared-types@0.0.0 build
npm notice run tsc
sh: 1: tsc: not found
npm error Lifecycle script `build` failed with error:
npm error code 127
npm error path /home/waitem/releases/parent:directory/mono-repo/packages/@waitem/shared-types
npm error workspace @waitem/shared-types@0.0.0
npm error location /home/waitem/releases/parent:directory/mono-repo/packages/@waitem/shared-types
npm error command failed
npm error command sh -c tsc

Note that if the parent directory is renamed from 'parent:directory' to 'parent-directory' the command npm -w @waitem/shared-types run build then works correctly

Expected Behavior

npm should be able to locate and run hoisted package bin files when the parent directory path contains a ':' colon character

Steps To Reproduce
  1. Unpack the attached issue9910_monorepo.tar.gz file
  2. cd parent:directory/project-name
  3. Run 'npm install'
  4. Run "npm -w packages/@waitem/shared-types run build"
  5. See error: sh: 1: tsc: not found

From limited testing, it appears that a ':' anywhere in the parent directory path is enough to cause the problem.

Environment
  • npm: 12.0.2
  • Node.js: v24.19.0
  • OS Name: Ubuntu 22.04 LTS
  • System Model Name: Dell
  • npm config:
; "user" config from /home/waitem/.npmrc

@waitem:registry = "https://npm.pkg.github.com"
//npm.pkg.github.com/:_authToken = (protected)

; node bin location = /home/waitem/.nvm/versions/node/v24.19.0/bin/node
; node version = v24.19.0
; npm local prefix = /home/waitem
; npm version = 12.0.2
; cwd = /home/waitem
; HOME = /home/waitem
; Run `npm config ls -l` to show all defaults.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by unpacking issue9910_monorepo.tar.gz and reproducing the failure from a parent directory containing a colon; run npm install, then npm -w packages/@waitem/shared-types run build. Trace the workspace binary lookup used by that command, and consider the issue done when the hoisted tsc binary is found and the build succeeds with the colon-containing path.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.