pnpm: ERR_PNPM_LINKED_PKG_DIR_NOT_FOUND for file:// links in devDependencies even when --prod is on

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

10.4.1

Which area(s) of pnpm are affected? (leave empty if unsure)

Dependencies resolver

Link to the code that reproduces this issue or a replay of the bug

No response

Reproduction steps

  1. Create the following package.json in an empty folder:
{
  "dependencies": {
    "express": "^4.21.2"
  },
  "devDependencies": {
    "slugify": "^1.6.6",
    "test-dep": "file:../test-dep"
  }
}

Execute pnpm i --prod.

Observe the error:

ERR_PNPM_LINKED_PKG_DIR_NOT_FOUND  Could not install from "/..../test-dep" as it does not exist.

This error happened while installing a direct dependency of /....

Describe the Bug

When you use a file:// link in the devDependencies and install with --prod instead of ignoring that dependency, it throws an error saying it could not install from there.

Expected Behavior

If I run pnpm i --prod I expect it to completely ignore the devDependencies. This happens if I use link:// instead of file:// but it should happen for file too.

Which Node.js version are you using?

v22.14.0

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

Ubuntu

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (7 by maintainers)

Commits related to this issue

Most upvoted comments

Oh, I forgot to tell you. The actual right way to do shamefully-hoist is to write a .npmrc file with the following content:

shamefully-hoist=true

Maybe it can be documented somewhere to avoid tripping somebody up in future.

https://github.com/pnpm/pnpm.io/pull/645