- Create
.npmrc
and include below content at the root of the project
engine-strict = true
- Add
engines
in package.json
{
"scripts" {
"preinstall": "npx -y only-allow pnpm",
},
"engines": {
"npm": "Please use pnpm instead of NPM to install dependencies",
"pnpm": ">= LATEST_PNPM_VERSION_USED", // ">= 8.9.2"
"node": "ALLOWED_NODE_VERSIONS" // "^18.13.0 || >=20.0.0"
}
}