While a lot of times, installing the latest version of Node.js via preferred package manager is enough, in some cases more flexibility is needed.
For example, sometimes there are several projects to work on, each of which relies on a specific Node.js version.
This blog post presents an overview of Node.js setup to support the above scenario.
There are two commonly used tools for managing multiple Node.js versions -nvm
andn
.
In this post, we will usenvm
.
Using nvm (Node Version Manager)
nvm
, or Node Version Manager, is a solution provided by Node.js team themselves. It is anopen source with straightforward installation and usage flow.
Install with the package manager of your choice. For macOS, I will use Homebrew:
brewinstallnvm
Next, let's check available Node.js versions:
nvm ls-remote
Let's install the first version:
nvminstall <version># Replace <version> with the desired version, e.g., 18.16.0
Installed versions could be checked with:
nvmls
To switch between versions:
nvm use <version># Replace <version> with the desired version
With that, the setup of multiple Node.js versions has been completed.
It is also possible to set the version as default one withnvm alias default <version>
.
Seethis answer for more details.
Finally, check the version withnode --version
command.
Resources
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse