pnpm: `pnpm` does not update `node_modules` when `node-linker=hoisted`

It seems that pnpm always run --lockfile-only=true when node-linker=hoisted.

https://github.com/pnpm/pnpm/blob/c38feff08f9a110ebab918c6a9a64ad38613adb3/packages/core/src/install/index.ts#L1038-L1042

pnpm version: 6.32.11

Code to reproduce the issue:

  1. Create a .npmrc, add node-linker=hoisted in any existing project.
  2. pnpm i with any existing package.json to build the node_modules folder.
  3. Add any new package, i.e. pnpm add nx

Expected behavior:

pnpm add / pnpm up should update the node_modules folder

Actual behavior:

The following warning popups when pnpm add or pnpm up is run

 WARN  `node_modules` is present. Lockfile only installation will make it out-of-date

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Reactions: 15
  • Comments: 21 (3 by maintainers)

Most upvoted comments

I’m getting this issue as well.

It seems to work fine. The warning should not be printed.

I don’t get it how the comments are related to this issue. The issue is about a warning message which should not be printed.

It seems that pnpm always run --lockfile-only=true when node-linker=hoisted.

This is the correct behaviour for node-linker=hoisted. pnpm updates the lockfile then it hoists the packages using info from the lockfiles. Lastly, it checks what is in the filesystem inside node_modules and makes changes if they are required.

If you have issues with node-linker=hoisted, stope commenting in this issue. Create a new issue with steps to reproduce.

OK, if you can create exact steps to reproduce, we can check.

Adding this to .npmrc fixed the issue for me:

shared-workspace-lockfile=true

how to solve this? trying to use workspaces and I have no clue why on earth this warning pops up upon a simple pnpm add 😵‍💫🔫

Same issue here. It started happening after setting node-linker to hoisted. Any way to avoid a complete reinstall of all paclages when only one package is added? Why exactly does it do that?