Skip to content

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

Description

@waitem

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions