-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Verify latest release
- I verified that the issue exists in the latest pnpm release
pnpm version
10.1.0
Which area(s) of pnpm are affected? (leave empty if unsure)
No response
Link to the code that reproduces this issue or a replay of the bug
https://gist.github.com/TomiBelan/c29d21ce9ac55354641bffbd9daa7171
Reproduction steps
- Have nonzero dependencies and nonzero devDependencies in package.json
- Enable
verify-deps-before-run=promptin .npmrc pnpm install --productionpnpm run some_script_name(e.g.pnpm run helloin the above gist)
Describe the Bug
pnpm asks: Your "node_modules" directory is out of sync with the "pnpm-lock.yaml" file. This can lead to issues during scripts execution. Would you like to run "pnpm install" to update your "node_modules"? (Y/n)
If you press y, pnpm will install devDependencies and run the script.
If you press n, pnpm will run the script as is.
Expected Behavior
pnpm should remember that the most recent install was done with --production. (Perhaps inside node_modules/.pnpm-workspace-state.json.)
If the most recent install was --production, pnpm run should compare if current node_modules directory content is in sync with package.json dependencies only. If they are in sync, it should not prompt, just run the script. If they are not in sync, it should offer: Would you like to run "pnpm install --production" to update your "node_modules"?, and do exactly that when you press y.
Same with pnpm exec of course.
(Side note: I acknowledge that scripts which need devDependencies may fail. But that's normal. E.g. in this gist, it is understandable that pnpm install --production ; pnpm run format will print prettier: not found. This bug report focuses on the behavior of pnpm run hello.)
Thank you for your work. <3
Which Node.js version are you using?
v23.6.1
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