Home > Web Front-end > JS Tutorial > body text

Teach you step by step how to use tools to switch node versions

青灯夜游
Release: 2021-10-26 18:56:56
forward
5158 people have browsed it

This article will introduce to you how to use tools to switch node versions, so that the node version can better meet the needs of the project and prevent errors. It has certain reference value and I hope it will be helpful to everyone!

Teach you step by step how to use tools to switch node versions

I have never been exposed to the situation where need to switch node versions, until one day, when running a project, an error occurred: ReferenceError: primordials is not defined, the reason for this error is that the node version I am using is too high, so I need to lower the node version. [Recommended learning: "nodejs Tutorial"]

Learn to use tools to switch node versions

In fact, on a computer It is relatively common to use different versions of node on the Internet, because you cannot guarantee that your current project is using the latest node. It does not rule out that there are old projects. When switching and use are frequent, you cannot uninstall and then reinstall.

At this time, you can use a node version management tool.

My computer is win, so I use nvm, and it works fine.

Download nvm and install it (recommended to use nvm-setup.zip) https://github.com/coreybutler/nvm-windows/releases

nvm basic command usage

View nvm installation version

nvm v
//或
nvm version
Copy after login

View all installable Node version numbers

nvm list available
Copy after login

View the installed node version

nvm ls
//或
nvm list
Copy after login

Install

//安装指定版本(推荐)
nvm install 14.8.0
Copy after login

Uninstall

// 14.8.0 是版本号
nvm uninstall 14.8.0
Copy after login

Use specified Version node

// 14.8.0 是版本号
nvm use 14.8.0
Copy after login

View all commands

nvm help
Copy after login

Write to the end

Why What about writing this article? On the one hand, it is because I sometimes forget easily, so I wrote an article to record it. On the other hand, these are actually some problems I encountered at work, and then I solved them by learning certain things. Of course, running the project successfully is only the first step. Every step you take next counts, come on!

over.

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

The above is the detailed content of Teach you step by step how to use tools to switch node versions. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:juejin.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template