# please-upgrade-node

> Displays a beginner-friendly message telling your user to upgrade their version of Node

Latest version **3.2.0** (published 2019-08-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install please-upgrade-node
pnpm add please-upgrade-node
yarn add please-upgrade-node
bun add please-upgrade-node
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 3.2.0 |
| Published | 2019-08-08 |
| First published | 2017-07-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 240 |
| Author | typicode |
| Maintainers | typicode |
| Keywords | node, engines, version, check, verify, upgrade |

## Links

- npm: https://www.npmjs.com/package/please-upgrade-node
- Repository: https://github.com/typicode/please-upgrade-node
- Homepage: https://github.com/typicode/please-upgrade-node#readme
- Issues: https://github.com/typicode/please-upgrade-node/issues
- npm.io page: https://npm.io/package/please-upgrade-node

## Dependencies (1)

- [semver-compare](https://npm.io/package/semver-compare.md) ^1.0.0

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 3.2.0 (latest) — 2019-08-08
- 3.1.1 — 2018-07-05
- 3.1.0 — 2018-07-02
- 3.0.2 — 2018-04-25
- 3.0.1 — 2017-07-31
- 3.0.0 — 2017-07-31
- 2.0.0 — 2017-07-24
- 1.0.1 — 2017-07-10
- 1.0.0 — 2017-07-08

## README

# Please upgrade Node [![](http://img.shields.io/npm/dm/please-upgrade-node.svg?style=flat)](https://www.npmjs.org/package/please-upgrade-node) [![Build Status](https://travis-ci.org/typicode/please-upgrade-node.svg?branch=master)](https://travis-ci.org/typicode/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
0.12

$ modern-cli
modern-cli requires at least version 6 of Node, please upgrade
```

## Support

If you like this project, you can support me on [GitHub Sponsors](https://github.com/users/typicode/sponsorship)

## 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

* [pkg-ok](https://github.com/typicode/pkg-ok) - :ok_hand: Prevents publishing a module with bad paths
* [husky](https://github.com/typicode/husky) - :dog: Git hooks made easy
* [update-notifier](https://github.com/yeoman/update-notifier) - Update notifications for your CLI app 

Thanks to [zeit/serve](https://github.com/zeit/serve) for the error message inspiration.

## License

MIT - [Typicode :cactus:](https://github.com/typicode) - [Patreon](https://patreon.com/typicode)

---
_Source: https://npm.io/package/please-upgrade-node · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
