npm-only-allow
The hook about preinstall of npm
behaves inconsistently across package managers.
The existing solution (only-allow
) is not working well.
The npm-only-allow
goal is to fix them.
usage
Add a postinstall
script to your project's package.json
.
If you want to force npm|cnpm|pnpm|yarn
, add:
(If you want to smooth out the difference, you also need to add it in the startup script)
{
"scripts": {
"postinstall": "npx npm-only-allow@latest --PM yarn",
"start": "npx npm-only-allow@latest && vite"
}
}
params
- PM
Set the package manager
- lang (en or zh)
Set the language category for error messages to be output , Default to English
Sample environment
node v14.19.0
npm v8.11.0
yarn v1.22.19
pnpm v7.2.7
cnpm v9.0.1
tips
If you are using 'cnpm' as your package manager, try pressing the space bar if loading is going on
Testing process
This is the testing process after the development is complete
You just have to choose one or the other
Let's take yarn
for example
{
"scripts": {
"postinstall": "npx npm-only-allow@latest --PM yarn",
"start": "npx npm-only-allow@latest && vite"
}
}
License
MIT