Automatically Switch Node.js Versions in VSCode with vsc-nvm

This guide explains how to configure VSCode with the vsc-nvm extension and a .nvmrc file so that the appropriate Node.js version is automatically selected each time you open a project, eliminating manual nvm use commands.

Programmer DD
Programmer DD
Programmer DD
Automatically Switch Node.js Versions in VSCode with vsc-nvm

In recent years I have built many static sites using Hexo and VuePress, and because different themes require different Node.js versions, I ended up with multiple Node.js versions installed locally.

I previously wrote an article about managing multiple Node.js versions with nvm; you can refer to that Node.js environment setup guide.

Even with nvm managing versions, the default version is single, so when opening different projects in VSCode you often have to run nvm use manually, which is cumbersome and easy to forget.

The ideal solution is to have VSCode automatically switch to the appropriate Node.js version when a project is opened.

Achieving this only requires two steps:

Step 1: Install the VSCode extension vsc-nvm.

Step 2: In the project root create a file named .nvmrc containing the desired Node.js version, for example: v10.13.0 After saving the configuration, close VSCode and reopen the project; the terminal opens automatically and runs nvm use, achieving automatic Node.js version switching.

That’s all for today; I hope you find this helpful.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Node.jsVSCodeversion-managementEnvironmentnvmrcvsc-nvm
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.