Skip to content

Prevent mixing npm and pnpm in the project #2623

@Gurkiratcodemaster

Description

@Gurkiratcodemaster

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 install creates a package-lock.json file, while the project already uses pnpm-lock.yaml.
  • npm installs dependencies using a flat node_modules structure, while pnpm uses a stricter and different layout.
  • pnpm-specific configuration in package.json may 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:

  1. Adding the following field to package.json:
"packageManager": "pnpm@10.3.0"
  1. Optionally adding a preinstall check to prevent npm or yarn installs:
"preinstall": "npx only-allow pnpm"
  1. 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.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions