Force a specific package manager and node version to be used on a project
npm i only-allow-engines --save
Add the engines field to your package.json, like this:
"engines": {
"node": ">=16",
"npm": ">8"
}
if you want to force pnpm, like this:
"engines": {
"node": ">=16",
"pnpm": ">6"
}
you can read more about engines in the npm docs
{
"scripts": {
"preinstall": "npx only-allow-engines"
}
}
const onlyAllowEngines = require('only-allow-engines');
onlyAllowEngines({
pnpm: ">=6",
node: ">=16.0.0",
})