Enforce the usage of a single package manager within your project.
There's no need to install the package. Just create a Git pre-commit hook and put the following command in there:
npx enforcepm <pm>
Where <pm>
is the name of the package manager you want to use within your project.
Currently only npm, yarn and pnpm are supported.
Feel free to open an issue requesting the implementation of your preferred package manager, or even better send a PR.
Since, currently, there is no clean way to prevent a package manager from running (see #4895), the approach chosen by enforcepm is to deals with the consequences of using the wrong package manager.
The main problem with using wrong package managers is the generation of lock files, which are redundant and may cause "consistency issues"
enforcepm deletes any staged lock file other than the desired ones. The deletion is meant to take place in a pre-commit hook.
Feel free to fill up issues and send pull requests for fixes or features.