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!
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
View all installable Node version numbers
nvm list available
View the installed node version
nvm ls //或 nvm list
Install
//安装指定版本(推荐) nvm install 14.8.0
Uninstall
// 14.8.0 是版本号 nvm uninstall 14.8.0
Use specified Version node
// 14.8.0 是版本号 nvm use 14.8.0
View all commands
nvm help
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!