Even though engineStrict is deprecated, you can still accomplish this behavior without needing to use an additional script to enforce a Node version in your project.
-
Add the
enginesproperty to yourpackage.jsonfile. For example:{ "name": "example", "version": "1.0.0", "engines": { "node": ">=14.0.0" } } -
Create a
.npmrcfile in your project at the same level as yourpackage.json. -
In the newly created
.npmrcfile, addengine-strict=true.engine-strict=true
This will enforce the engines you’ve defined when the user runs npm install. I’ve created a simple example on GitHub for your reference.