Skip to content

Instantly share code, notes, and snippets.

@jareware
Last active October 30, 2020 18:36
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jareware/e2ea96f5eac4a530e66f0ee313ee07bb to your computer and use it in GitHub Desktop.
Save jareware/e2ea96f5eac4a530e66f0ee313ee07bb to your computer and use it in GitHub Desktop.
Enforcing the engines property of package.json

Document your target environment with:

"engines": {
  "npm": ">=3.3.12 <4",
  "node": ">=5.5.0 <6"
},

Then install this:

"devDependencies": {
  "check-node-version": "1.1.0"
}

And barf when running on an incompatible platform:

"scripts": {
  "build": "check-node-version --package && ...",
  "watch": "check-node-version --package && ..."
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment