supporting semver checking, forked from please-upgrade-node@3.1.1
💁 show a message to your users to upgrade Node instead of a stacktrace
It's common for new Node users to miss or not understand engines warning when installing a CLI. This package displays a beginner-friendly message if their Node version is below the one expected.
$ node -v0.12 $ modern-climodern-cli requires at least version 6 of Node, please upgrade
Usage
npm install please-upgrade-node-fork
Add please-upgrade-node-fork
at the top of your CLI
#!/usr/bin/env nodeconst pkg = pkg // <- Must run BEFORE requiring any other modules // ...
Set in your package.json
the required Node version
"engines": "node": ">=6"
Options
You can set custom exitCode
and message
function if needed
Important: to keep message
function compatible with older versions of Node, avoid using ES6 features like =>
or string interpolation.
See also
- pkg-ok - 👌 Prevents publishing a module with bad paths
- husky - 🐶 Git hooks made easy
- update-notifier - Update notifications for your CLI app
Thanks to zeit/serve for the error message inspiration.
License
MIT - Typicode 🌵 - Patreon