please-upgrade-node

3.2.0last stable release 5 years ago
Complexity Score
Low
Open Issues
N/A
Dependent Projects
200
Weekly Downloadsglobal
3,696,147

License

  • MIT
    • Yesattribution
    • Permissivelinking
    • Permissivedistribution
    • Permissivemodification
    • Nopatent grant
    • Yesprivate use
    • Permissivesublicensing
    • Notrademark grant

Downloads

Readme

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.

$ 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

npm install please-upgrade-node

Add please-upgrade-node at the top of your CLI

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

{
  "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

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 - βœ… Simple test runner
  • husky - πŸ• Git hooks made easy

Dependencies

CVE IssuesActive
0
Scorecards Score
3.00
Test Coverage
No Data
Follows Semver
Yes
Github Stars
241
Dependenciestotal
7
DependenciesOutdated
6
DependenciesDeprecated
0
Threat Modelling
No Data
Repo Audits
No Data

Learn how to distribute please-upgrade-node in your own private NPM registry

npm config set registry  https://npm.cloudsmith.com/owner/repo
Processing...
Done
npm install please-upgrade-node
Processing...
Done

9 Releases

NPM on Cloudsmith

Getting started with NPM on Cloudsmith is fast and easy.