Home>Article>Web Front-end> How does Node.js perform version management? 3 practical version management tools to share

How does Node.js perform version management? 3 practical version management tools to share

青灯夜游
青灯夜游 forward
2022-08-10 20:20:30 7079browse

NodeHow to perform version management? The following article will share with you 3 very practical Node.js version management tools. I hope it will be helpful to you!

How does Node.js perform version management? 3 practical version management tools to share

In the previous article "What are the differences between various versions of Node.js? How to choose the right version?" introduced that Node.js versions are divided into LTS and Current series. When we need to install both the LTS version and the Current version in the local development environment, we need to perform version management on the Node.js version.

For example, Node.js 8.0.0 and Node.js 17.0.0 need to be installed locally.

In order to be able to version manage theNode.jsversion, I have compiled 3 very practical Node.js version management tools, allowing everyone to freely switch to Node in different local environments. js version.

1. nvm

Github stars: 60K

nvmis a Node. js version management tool, allowing users to quickly install, switch and manage different Node.js versions through the command line.

How does Node.js perform version management? 3 practical version management tools to share

Image from:github

nvm is only a project for macOS and Linux users, if you are a Windows user, you can use# Replace with ##nvm-windows,nodistornvs.

Installation method

macOS download method:

# 方式1 浏览器打开下面链接下载 https://github.com/nvm-sh/nvm/blob/v0.39.1/install.sh # 下载完成后,通过命令安装 sh install.sh # 方式2 推荐 curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash # 方式3 wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
If you encounter some strange problems during the installation process, you can check the

nvm supplement illustrate.

Common commands
nvm ls # 查看版本安装所有版本 nvm ls-remote # 查看远程所有的 Node.js 版本 nvm install 17.0.0 # 安装指定的 Node.js 版本 nvm use 17.0.0 # 使用指定的 Node.js 版本 nvm alias default 17.0.0 # 设置默认 Node.js 版本 nvm alias dev 17.0.0 # 设置指定版本的别名,如将 17.0.0 版本别名设置为 dev

How does Node.js perform version management? 3 practical version management tools to share

2. n

Github stars: 16.7K

nis an interactive Node.js version management tool. It has no subscripts, no configuration files, and no complex API. It is very easy to use. Simple.

How does Node.js perform version management? 3 practical version management tools to share

#n Only available on macOS and Linux, not Windows.

Installation method

You can use npm to install directly globally:

npm install n -g

Common commands
n # 显示所有已下载版本 n 10.16.0 # 下载指定版本 n lts # 查看远程所有 LTS Node.js 版本 n run 10.16.0 # 运行指定的 Node.js 版本

Enter

n -hto view the help information. The main commands are as follows:

n Display downloaded Node.js versions and install selection n latest Install the latest Node.js release (downloading if necessary) n lts Install the latest LTS Node.js release (downloading if necessary) n  Install Node.js  (downloading if necessary) n install  Install Node.js  (downloading if necessary) n run  [args ...] Execute downloaded Node.js  with [args ...] n which  Output path for downloaded node  n exec   [args...] Execute command with modified PATH, so downloaded node  and npm first n rm  Remove the given downloaded version(s) n prune Remove all downloaded versions except the installed version n --latest Output the latest Node.js version available n --lts Output the latest LTS Node.js version available n ls Output downloaded versions n ls-remote [version] Output matching versions available for download n uninstall Remove the installed Node.js

3. fnm

Github stars: 8.4K

fnmis a fast and simple Node.js version manager, built using Rust.

How does Node.js perform version management? 3 practical version management tools to share

Image from:

freecodecamp

Main features include:

    ? Cross-platform support, including : macOS, Windows, Linux;
  • ✨ Single file, easy installation, instant startup;
  • ? Designed with speed in mind;
  • ? Applicable to
  • .node -versionand.nvmrcfiles;

Installation method

macOS/Linux environment:

# bash, zsh and fish shells curl -fsSL https://fnm.vercel.app/install | bash
Windows environment:

# 管理员模式打开终端,安装后只能使用管理员模式打开使用 choco install fnm # 安装完成还需要手动设置环境变量
Linux/macOS/Windows environment can also directly download the binary file for installation, download address:

github.com/Schniz/fnm/…

Commonly used commands
fnm -h # 查看帮助 fnm install 17.0.0 # 安装指定 Node.js 版本 fnm use 17.0.0 # 使用指定 Node.js 版本 fnm default 17.0.0 # 设置默认 Node.js 版本

Summary

This article recommends 3 very commonly used Node.js version management tools, which you can use according to your actual needs. Choose to use.

If you have better tools, please leave a message to share.

For more node-related knowledge, please visit:nodejs tutorial!

The above is the detailed content of How does Node.js perform version management? 3 practical version management tools to share. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:juejin.cn. If there is any infringement, please contact admin@php.cn delete