Small knowledge, big challenge! This article is participating in the creation activity of “Essential Tips for Programmers”.

preface

I didn’t see the need to switch node versions until I ran a project and got an error: 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.

Learn how to switch node versions using tools

It’s common to have different versions of Node on a single computer, because you can’t guarantee that your current project will use the latest version of Node, not to mention older projects, and you can’t uninstall and reinstall when you’re switching over frequently.

A Node version management tool is available at this point.

My computer is Win, so I use NVM, and it works fine.

Download and install NVM (nVM-setup.zip is recommended) github.com/coreybutler…

NVM basic command usage

View the NVM installation version

NVM V // or NVM versionCopy the code

View all installable Node versions

nvm list available
Copy the code

View the installed Node version

NVM ls // or NVM listCopy the code

The installation

// Install the specified version (recommended)Copy the code

uninstall

NVM uninstall 14.8.0 is the version numberCopy the code

Use the specified version of Node

// 14.8.0 is the version number NVM use 14.8.0Copy the code

View all commands

nvm help
Copy the code

Wrote last

Why write this article? On the one hand, I tend to forget sometimes, so I write an article to record it. On the other hand, this is actually some problems encountered in work, and then through learning something, and solved. Of course, the successful operation of the project is only the first step, the next step counts, come on!

To the end.