pnpm: "Broken lockfile: no entry for" when 'pnpm install --no-optional'

pnpm version:

6.32.3

Code to reproduce the issue:

package.json and pnpm-lock.yaml at https://gist.github.com/MBelniak/e9a14fcc72e20b2e0355aa3b25278eec

pnpm install --no-optional and also, then: pnpm install --no-optional --no-frozen-lockfile

Expected behavior:

Lockfile is fixed after adding ‘–no-frozen-lockfile’ or more appropriate hint is displayed.

Actual behavior:

Lockfile is not fixed, the same error and hint are displayed.

Lockfile is up-to-date, resolution step is skipped
 WARN  Broken lockfile: no entry for '/uglify-js/3.8.1' in pnpm-lock.yaml
 ERR_PNPM_ERR_PNPM_LOCKFILE_MISSING_DEPENDENCY  The lockfile is broken! Resolution step will be performed to fix it.
 WARN  deprecated @types/redux@3.6.0: This is a stub types definition for Redux (https://github.com/reactjs/redux). Redux provides its own type definitions, so you don't need @types/redux installed!
 WARN  deprecated @stylelint/postcss-markdown@0.36.2: Use the original unforked package instead: postcss-markdown

optionalDependencies: skipped

 WARN  Issues with peer dependencies found
.
├─┬ @typescript-eslint/eslint-plugin
│ └── ✕ missing peer @typescript-eslint/parser@^4.0.0
├─┬ postcss-loader
│ └── ✕ missing peer postcss@"^7.0.0 || ^8.0.1"
└─┬ ts-jest
  └── ✕ missing peer jest@">=26 <27"
Peer dependencies that should be installed:
  @typescript-eslint/parser@^4.0.0  jest@">=26 <27"                   postcss@"^7.0.0 || ^8.0.1"        

 ERR_PNPM_LOCKFILE_MISSING_DEPENDENCY  Broken lockfile: no entry for '/uglify-js/3.8.1' in pnpm-lock.yaml

This issue is probably caused by a badly resolved merge conflict.
To fix the lockfile, run 'pnpm install --no-frozen-lockfile'.
Progress: resolved 1115, reused 1115, downloaded 0, added 0

Additional information:

Removing --no-optional fixes this issue.

  • node -v prints: v14.15.4
  • Windows, macOS, or Linux?: Linux

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 8
  • Comments: 18 (3 by maintainers)

Most upvoted comments

I encountered the same issue, just manually adding the missing dependency to your package.json and pnpm install again solves the issue apparently.

In my case the error message was:

 ERR_PNPM_LOCKFILE_MISSING_DEPENDENCY  Broken lockfile: no entry for '/webpack/4.46.0' in pnpm-lock.yaml

So I open pnpm-lock.yaml and search webpack@4.46.0 then I noticed the package next-fonts was the one needing that dependency, so I opened the package.json where I am using next-fonts in my monorepo and added that webpack@4.46.0 dep there.

Finally pnpm install and pnpm no longer complains about that. Note: tested with --prod and --no-optional. I am also using node-linker=hoisted. In all those cases it works fine.

I’m having this issue as well, pnpm complains about not finding a dep on the lock file but the lock file has that dependency. It only happens when installing packages using the -P/–prod flag. I’m using the node-linker=hoisted option by the way.

ERR_PNPM_LOCKFILE_MISSING_DEPENDENCY  Broken lockfile: no entry for '/webpack/5.73.0' in pnpm-lock.yaml

@zkochan

I have the same issue, I need to enable the node-linker=hoisted option because of the facebook/metro issue. But when I enable this option, I get this error.

The same error with node-linker=hoisted & pnpm i --no-optional --frozen-lockfile. Is there any news?

i have the same question.when i use pnpm 7.4.0 and this commder pnpm --filter=xxx deploy dist error is  ERR_PNPM_LOCKFILE_MISSING_DEPENDENCY  Broken lockfile: no entry for '/sass/1.53.0' in pnpm-lock.yaml