Skip to content

Checks the project and uses nvm or n to fix the node version

Notifications You must be signed in to change notification settings

tzdesign/node-package-version

Repository files navigation

node-package-version

This is small tool will check the engines.node version and uses nvm or n to install the latest version matching the string. If it's a pretty open range like >=18.0.0 for example. It will determine and install node LTS.

Usage

$ npm install -g node-package-version
$ npv COMMAND
running command...
$ npv (--version)
node-package-version/0.0.7 darwin-x64 node-v16.20.2
$ npv --help [COMMAND]
USAGE
  $ npv COMMAND
...

Commands

npv fix

Fix node version by using nvm or n based on package.json

USAGE
  $ npv fix

DESCRIPTION
  Fix node version by using nvm or n based on package.json

See code: dist/commands/fix/index.ts

npv help [COMMANDS]

Display help for npv.

USAGE
  $ npv help [COMMANDS] [-n]

ARGUMENTS
  COMMANDS  Command to show help for.

FLAGS
  -n, --nested-commands  Include all nested commands in the output.

DESCRIPTION
  Display help for npv.

See code: @oclif/plugin-help

Use as pre command with zsh

Just add this code at the end of your .zshrc file.

precmd(){
    npv fix
}

If you go into a new terminal in vscode or cd into a project, it will check the node version and will switch it.