Skip to content

[BUG] install-strategy=linked: npm link <path> (local path) fails with ENOENT in global node_modules #9621

Closed

Description

@manzoorwanijk

Part of #9608.

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

Under install-strategy=linked, npm link <path> (linking a local directory by path) fails with npm error code ENOENT for <global-prefix>/lib/node_modules/<pkg>/package.json — it looks in the global node_modules instead of the provided path (exit 254). The global-name form npm link <pkg> works. The hoisted strategy handles the path form.

Expected Behavior

npm link <path> should link the package at the given filesystem path under the linked strategy, matching the hoisted strategy and the handling of file:<path> dependencies.

Steps To Reproduce

mkdir -p /tmp/lp-pkg && echo '{ "name": "lp-pkg", "version": "1.0.0" }' > /tmp/lp-pkg/package.json
cd "$(mktemp -d)"
echo 'install-strategy=linked' > .npmrc
echo '{ "name": "consumer", "version": "1.0.0" }' > package.json
npm link /tmp/lp-pkg
#   linked:  npm error code ENOENT ... /lib/node_modules/lp-pkg/package.json   (exit 254)
#   hoisted: links it, require('lp-pkg') resolves

Environment

  • npm: 12.0.0-pre.1 (latest)
  • Node.js: v24.17.0
  • OS Name: macOS (Darwin 25.5.0)
  • System Model Name: MacBook (arm64)
  • npm config:
install-strategy=linked

Activity

  1. manzoorwanijk commented on Jun 25, 2026

    @manzoorwanijk
    ContributorAuthor

    Correction: This was a bug on npm v10, not v12, and has already been fixed by #9167.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions