Working with packageManager: pnpm. Working in a project that commits changes to git, we are changes branches during work. Checking in into a new branch that contains changes in one or both: package.json, pnpm-lock.yaml. We detect this change and and decide we need to update node_modules.
Do we need to delete node_modules before running pnpm install ?
Working with npm it was best practice to delete node_modules to be ensure all packages with their exact version as in package-lock file will be installed, otherwise modules that are already been exist in node_modules might be skipped.
No, there is no need to delete node_modules.
The only case when a deletion might be recommended is when changing some configuration settings in .npmrc
. But even in those cases pnpm mostly deletes node_modules automatically.
Any scenario that requires manual deletion can be considered a bug.