How to Switch Node.js Versions
Thank you for your continued support.
This article contains advertisements that help fund our operations.
Table Of Contents
関連動画
Related Video
This is a video where we actually tried out the content from the article! If anything is unclear in the article, please check out the video.
The video provides further explanations and demonstrations, so it should be helpful.
Subscribe to Our Channel
If you found this video helpful, please consider subscribing to our channel or giving it a thumbs up! It really motivates us to create more content.
Questions and Feedback
If you have any questions or feedback regarding this article or the video, feel free to leave them in the comment section of the video. Your input is greatly appreciated and will help us improve our content in the future!
This article summarizes how to switch between different versions of Node.js.
Install Volta
If you're on macOS:
curl https://get.volta.sh | bash
If you're on Windows:
winget install Volta.Volta
That’s all it takes to install Volta easily.
volta -v
2.0.2
Just Specify the Version You Want to Use
You can install a version or set it as the default using the following commands:
If the version has already been installed once, it will switch instantly without re-downloading.
volta install node@20.19.0
Or simply:
volta install node@20
You can also use it with Yarn:
volta install yarn@3
If You Want Different Versions per Project
volta pin node@16
With the pin
command, you can specify the Node.js version to be used for each project.
This version info is stored in the package.json
file. If package.json
is missing, this command will result in an error.
{
"name": "node20",
"version": "1.0.0",
// omitted
"volta": {
"node": "20.18.0"
}
}
Switching Node.js versions has never been easier.
The process of switching versions is often referred to as "version management," so if you're curious to learn more, try searching with that term.
I hope this helps someone out there!