Giter Club home page Giter Club logo

please-upgrade-node's Introduction

Please upgrade Node npm

๐Ÿ’ 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.