npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nvm-node-version-checker

v1.0.3

Published

A utility to ensure the correct Node.js version is being used with NVM. If the specified version is not installed, the script will automatically install it and set it as the active version.

Downloads

32

Readme

Node.js Version Checker with NVM

This package is a simple script to check if the currently installed version of Node.js matches a specified version. If the version does not match, the script will automatically switch to the required version using NVM (Node Version Manager), and install it if necessary.

This is especially useful when working on multiple projects with different Node.js versions. For example, you can add a prestart script like prestart: nvm-node-version-checker 22.8.0 in your package.json to ensure the correct version of Node.js is used before starting the project.

Features

  • Ensures the required Node.js version is being used.
  • Automatically installs the specified version via NVM if not present.
  • Uses the correct Node.js version after installation.
  • Adds a small delay to ensure the environment is loaded correctly.

Prerequisites

  1. NVM (Node Version Manager): This script requires NVM to be installed on your system. You can install it by following the instructions at NVM's GitHub repository (Here's NVM for Windows).

Installation

Run npm i -D nvm-node-version-checker

Usage

Run by passing the desired Node.js version as an argument:

nvm-node-version-checker <version>

For example, to ensure you're using Node.js version 14.17.0, you can run:

nvm-node-version-checker 14.17.0

What the Script Does:

  1. Checks if the required version of Node.js is provided.
  2. Verifies the currently installed version of Node.js.
  3. If the installed version does not match the required version:
    • It checks if NVM is installed.
    • If NVM is installed, it will install the required version of Node.js using NVM.
    • It switches to the required version via NVM.
    • A 2-second delay is introduced to ensure the correct version is loaded.
  4. If the required version is already installed, the script confirms it and exits.

Error Handling

  • If NVM is not installed, the script will terminate and ask you to install NVM.
  • If the required Node.js version is not provided as a command-line argument, the script will terminate with an error.

Example

$ nvm-node-version-checker 14.17.0
Current Node.js version (v12.22.0) is not 14.17.0.
nvm is installed, proceeding with version change...
Installing Node.js version 14.17.0 via nvm...
Switching to Node.js version 14.17.0 via nvm...
Node.js version loaded successfully.
Process completed, ready to go!

Node 22.9.0 is used to develop this package

License

This project is licensed under the MIT License.