DEV Community

AquaCat
AquaCat

Posted on

【Node.js】How to manage Node.js of different versions

OS...Windows 10

Here is what I did to manage different versions of node in my PC. You can switch different versions of node depending on your project directories.

Install "volta" to switch different version of node!"

1.Go to [(https://docs.volta.sh/guide/getting-started)].
2.Click "download and run the Windows installer" to download the installer.
3.Click the installer to install volta.
4.Go to your project directory to check your node version.
My node version is v14.

node -v
v14.15.4
Enter fullscreen mode Exit fullscreen mode

5.Install node of whatever version you like.
I installed the latest one.

volta install node @latest
Enter fullscreen mode Exit fullscreen mode

6.Make sure your desired version of node was installed.

volta list node
⚡️ Node runtimes in your toolchain:
    v19.3.0 (default)
Enter fullscreen mode Exit fullscreen mode

Looks like my original version of node is not on the list, so I added one.

volta install node@14.15.4
success: installed and set node@14.15.4 (with npm@6.14.10) as default
Enter fullscreen mode Exit fullscreen mode

I got v14 as well.

volta list node
⚡️ Node runtimes in your toolchain:

    v14.15.4 (default)
    v19.3.0
Enter fullscreen mode Exit fullscreen mode

7.You can pin the node in your project directory.

volta pin node@19.3.0
success: pinned node@19.3.0 (with npm@9.2.0) in package.json
Enter fullscreen mode Exit fullscreen mode

In this project directory, v19.3.0 is used. On the other hand, in other project directories, v14.15.4 is used.

Top comments (0)