axetroy / virtual-node-env

A virtual node environment for node.js, node version manager for projects.

Home Page:https://www.npmjs.com/package/@axetroy/virtual-node-env

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status Go Report Card Latest Version 996.icu Repo Size

virtual-node-env

A tool similar to virtualenv, used to set a specific node version for a specified project, which is used to meet the needs of different node versions of different projects.

It is similar to nvm, but not a replacement for nvm. nvm manages the global node version for you, and can even switch node versions temporarily.

virtual-node-env can also switch node versions, but not globally, but following the project.

Note

In actual project development, you may encounter situations where several projects depend on different node versions. For example 12.x.y / 16.x.y / 20.x.y.

They are not fully compatible, so you need node version management tools, such as nvm. And it requires manual version switching, not automatic. In my project, there are some automatic CIs, so the node version needs to automatically follow the project.

Features

  • Cross-platform supports. including windows
  • Automatically download node
  • Support use command to switch node version temporarily

Usage

# Start a new shell with the specified node version
$ virtual-node-env use 16.20.0
$ node -v
16.20.0

# Specify the node version and run the specified command
$ virtual-node-env use 18.20.0 node -v
v18.20.0

or put it into package.json

npm install @axetroy/virtual-node-env --save-exact -D
 "scripts": {
    "install-deps": "virtual-node-env use 16.20.0 npm install",
    "build": "virtual-node-env use 16.20.0 npm build"
  },

more usage, please run virtual-node-env --help

$ virtual-node-env --help
virtual-node-env - Virtual node environment, similar to nvm

USAGE:
virtual-node-env [OPTIONS] use <VERSION> [COMMAND]
virtual-node-env [OPTIONS] clean
virtual-node-env [OPTIONS] ls|list
virtual-node-env [OPTIONS] ls-remote|list-remote

COMMANDS:
  use <VERSION> [COMMAND]  Use the specified version of node to run the command
  clean                    Clean the virtual node environment
  ls|list                  List all the installed node version
  ls-remote|list-remote    List all the available node version

OPTIONS:
  --help                   Print help information
  --version                Print version information
  --config                 Specify the configuration file. Detected .virtual-node-env.json automatically if not specified.

ENVIRONMENT VARIABLES:
  NODE_MIRROR              The mirror of the nodejs download, defaults to: https://nodejs.org/dist/
                           Chinese users defaults to: https://registry.npmmirror.com/-/binary/node/
  NODE_ENV_DIR             The directory where the nodejs is stored, defaults to: $HOME/.virtual-node-env
  DEBUG                    Print debug information when set DEBUG=1

SOURCE CODE:
  https://github.com/axetroy/virtual-node-env

Install

  1. Install via Cask (Mac/Linux/Windows)
$ cask install github.com/axetroy/virtual-node-env
$ virtual-node-env --help
  1. Install via npm
$ npm install @axetroy/virtual-node-env -g
$ virtual-node-env --help

Uninstall

$ virtual-node-env clean
# then remove the binary file

Configuration

Your can specify the configuration file by --config option, or put a .virtual-node-env.json file in the root of your project.

{
  "node": "v16.20.0"
}

then you can run virtual-node-env without specify the version

$ virtual-node-env node -v
v16.20.0

Similar Projects

https://github.com/jdx/mise

https://github.com/gvcgo/version-manager

https://github.com/version-fox/vfox

License

The Anti-996 License

About

A virtual node environment for node.js, node version manager for projects.

https://www.npmjs.com/package/@axetroy/virtual-node-env

License:Other


Languages

Language:Go 79.8%Language:JavaScript 18.0%Language:Makefile 2.2%