Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/typicode/please-upgrade-node
:information_desk_person: Show a message to your users to upgrade Node instead of a stacktrace
https://github.com/typicode/please-upgrade-node
cli engines node package upgrade version
Last synced: 5 days ago
JSON representation
:information_desk_person: Show a message to your users to upgrade Node instead of a stacktrace
- Host: GitHub
- URL: https://github.com/typicode/please-upgrade-node
- Owner: typicode
- License: mit
- Created: 2017-07-08T13:26:56.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-05-15T04:00:36.000Z (over 1 year ago)
- Last Synced: 2025-01-18T14:14:24.596Z (12 days ago)
- Topics: cli, engines, node, package, upgrade, version
- Language: JavaScript
- Homepage:
- Size: 124 KB
- Stars: 241
- Watchers: 5
- Forks: 13
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Please upgrade Node [![](http://img.shields.io/npm/dm/please-upgrade-node.svg?style=flat)](https://www.npmjs.org/package/please-upgrade-node) [![npm](https://img.shields.io/npm/v/please-upgrade-node.svg)](https://www.npmjs.com/package/please-upgrade-node)
> :information_desk_person: 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.
```sh
$ node -v
12$ modern-cli
modern-cli requires at least version 16 of Node, please upgrade
```## Status
**This project is considered feature complete and stable**. Only maintenance updates will be published. That said since the goal of the project is to check previous versions of Node, code is unlikely to be modified as it needs to work on very old versions.
## Usage
```sh
npm install please-upgrade-node
```Add `please-upgrade-node` at the top of your CLI
```js
#!/usr/bin/env node
const pkg = require('./package.json')
require('please-upgrade-node')(pkg) // <- Must run BEFORE requiring any other modules// ...
```Set in your `package.json` the required Node version
```js
{
"engines": {
"node": ">=6"
}
}
```__Important__: `>=` is the only operator supported by `please-upgrade-node` (e.g. `>=6`, `>=6.0`, `>=6.0.0`).
## Options
You can set custom `exitCode` and `message` function if needed
```js
pleaseUpgradeNode(pkg, {
exitCode: 0, // Default: 1
message: function(requiredVersion) {
return 'Oops this program require Node ' + requiredVersion
}
})
```__Important__: to keep `message` function compatible with older versions of Node, avoid using ES6 features like `=>` or string interpolation.
## See also
* [xv](https://github.com/typicode/xv) - ✅ Simple test runner
* [husky](https://github.com/typicode/husky) - 🐕 Git hooks made easy