Home  >  Article  >  Web Front-end  >  How to use nvm tool to manage node version? Method introduction

How to use nvm tool to manage node version? Method introduction

青灯夜游
青灯夜游forward
2020-12-08 17:46:033021browse

How to use nvm tool to manage node version? Method introduction

Related recommendations: "node js tutorial"

nvm is a popular way to run Node.js. For example, it makes it easy to switch Node.js versions, as well as install a new version to try out and easily roll back if something goes wrong.

This is useful for testing code with older versions of Node.js.

1. Install nvm

Execute brew install nvm, then the report:

How to use nvm tool to manage node version? Method introduction

Error 1: Need to create an nvm The file is used to load the content of nvm
//在命令行执行:
mkdir ~/.nvm
Error 2: You need to add the following blue selected configuration to the ~/.zshrc file
//用vim打开该文件
vim ~/.zshrc 

//按i进入书写模式 把蓝色内容黏贴在下方
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh"  # This loads nvm
[ -s "/usr/local/opt/nvm/etc/bash_completion" ] && . "/usr/local/opt/nvm/etc/bash_completion"

//按esc键 :wq保存退出

//此时再次执行brew install nvm还是如图一的报错。那是配置的.zshrc文件没生效。
//因此要在保存.zshrc文件后,在命令行执行使配置生效:
source ~/.zshrc

Enter nvm again. At this time, nvm has been installed. Yes, as well as its information and commands

How to use nvm tool to manage node version? Method introduction

2. nvm routine operations

How to use nvm tool to manage node version? Method introduction

mark only For reference, corrections and additions are welcome. Thanks

For more programming-related knowledge, please visit: Programming Teaching! !

The above is the detailed content of How to use nvm tool to manage node version? Method introduction. For more information, please follow other related articles on the PHP Chinese website!

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