Prevent mixing npm and pnpm in the project
Problem
The project currently uses pnpm for dependency management, but it is still possible to run commands using npm.
Because of this, contributors may accidentally run:
npm install
instead of:
pnpm install
This can introduce conflicts in the repository.
Conflicts that can happen
When npm and pnpm are used side by side, several problems may occur:
- Running
npm installcreates a package-lock.json file, while the project already uses pnpm-lock.yaml. - npm installs dependencies using a flat
node_modulesstructure, while pnpm uses a stricter and different layout. - pnpm-specific configuration in
package.jsonmay be ignored when npm is used. - The dependency tree may become inconsistent between contributors' environments.
- Builds or scripts may behave differently depending on which package manager was used.
These issues make debugging harder and reduce reproducibility for contributors and CI.
Proposed solution
To prevent these issues, the project could enforce pnpm usage by:
- Adding the following field to
package.json:
"packageManager": "[email protected]"
- Optionally adding a preinstall check to prevent npm or yarn installs:
"preinstall": "npx only-allow pnpm"
- Updating documentation to consistently use:
pnpm install
pnpm run <script>
Question
If this sounds like a useful improvement, may I work on implementing this change?
This would be my first contribution to the project, and I would be happy to help improve the setup for contributors.
@Gurkiratcodemaster I have assigned you. Thanks for reporting.
Hi @sydseter, I see this issue was unassigned recently — I'd like to work on it if it's still open.
I reviewed the earlier closed PR (#2624) for context. The overall approach looks right:
- Adding
"packageManager": "pnpm@<version>"topackage.json - Adding a
preinstallscript usingonly-allow pnpmto block npm/yarn installs - Updating documentation to consistently use
pnpmcommands
I noticed two small requested changes on that PR were never addressed before it was closed for inactivity — the .pre-commit-config.yaml version bump and a duplicate "Development server" headline in the README. I'll keep my PR scoped strictly to what's needed for this issue and avoid unrelated changes like that.
Happy to be assigned — thank you!
@prajakta128 Thank you for your time. I have assigned you.