I am searching for a way to break the build, if a user is using a different node.js version as defined in the project.
Ideally to put some checks in grunt or bower or npm to stop, if a certain npm/node version is not used to run the current build.
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 engines
property to your package.json
file. For example:
{ "name": "example", "version": "1.0.0", "engines": { "node": ">=14.0.0" } }
Create a .npmrc
file in your project at the same level as your package.json
.
In the newly created .npmrc
file, add engine-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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With