Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
October 12, 2022 06:07 pm GMT

Setting the Default Node.JS version with nvm

When developing projects and products in Node.JS, it becomes essential to set the Node.JS version being used on your computer. nvm is a really useful tool for changing your Node.JS version on the fly. If you need to install nvm, you can learn how to do that here.

nvm also lets you set the default version of Node.JS so that you don't have to constantly change it. To do that, you can use the nvm command like so:

nvm alias default 18.10.0

Before you do that, though, make sure you have the version you want to use installed. You can do that using nvm install:

nvm install 18.10.0

If you want to see what versions are available for you to set as your default version of Node.JS, try using nvm ls, which will return a list likethe one below. It also states which version is set as the default, beside the default -> node line.

 nvm ls       v14.15.1        v16.4.0       v16.13.2       v16.14.0->      v18.3.0         systemdefault -> node (-> v18.3.0)iojs -> N/A (default)unstable -> N/A (default)node -> stable (-> v18.3.0) (default)stable -> 18.3 (-> v18.3.0) (default)lts/* -> lts/gallium (-> N/A)lts/argon -> v4.9.1 (-> N/A)lts/boron -> v6.17.1 (-> N/A)lts/carbon -> v8.17.0 (-> N/A)lts/dubnium -> v10.24.1 (-> N/A)lts/erbium -> v12.22.12 (-> N/A)lts/fermium -> v14.20.0 (-> N/A)lts/gallium -> v16.17.0 (-> N/A)

Also, running node -v will show you which version you are currently using. If it's not the one you want, you can set it back to the default using nvm use default:

 node -vv16.18.0 nvm use defaultNow using node v18.3.0 (npm v8.11.0)

Original Link: https://dev.to/smpnjn/setting-the-default-nodejs-version-with-nvm-54c3

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To