What is only-allow?
The 'only-allow' npm package is used to enforce the use of a specific package manager in a project. This ensures that all contributors use the same package manager, which can help avoid issues related to package-lock files and dependency management.
What are only-allow's main functionalities?
Enforce npm usage
This feature ensures that npm is the only package manager allowed for the project. If a user tries to install dependencies using a different package manager, the installation will fail.
/* Add this to your package.json file */
{
"scripts": {
"preinstall": "npx only-allow npm"
}
}
Enforce yarn usage
This feature ensures that yarn is the only package manager allowed for the project. If a user tries to install dependencies using a different package manager, the installation will fail.
/* Add this to your package.json file */
{
"scripts": {
"preinstall": "npx only-allow yarn"
}
}
Enforce pnpm usage
This feature ensures that pnpm is the only package manager allowed for the project. If a user tries to install dependencies using a different package manager, the installation will fail.
/* Add this to your package.json file */
{
"scripts": {
"preinstall": "npx only-allow pnpm"
}
}
0
only-allow
Force a specific package manager to be used on a project
Usage
Add a preinstall
script to your project's package.json
.
If you want to force npm, add:
{
"scripts": {
"preinstall": "npx only-allow npm"
}
}
If you want to force cnpm, add:
{
"scripts": {
"preinstall": "npx only-allow cnpm"
}
}
If you want to force pnpm, add:
{
"scripts": {
"preinstall": "npx only-allow pnpm"
}
}
If you want to force yarn, add:
{
"scripts": {
"preinstall": "npx only-allow yarn"
}
}
If you want to force bun, add:
{
"scripts": {
"preinstall": "npx only-allow bun"
}
}
License
MIT