Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set node version differently for specific project(folder) via NVM

Tags:

node.js

nvm

I know I can change the node version by nvm use CLI command. However, I want to set specific node version differently for a certain project(folder). It's changed via nvm use command but it's reverted to default version whenever I restart the terminal or webstorm IDE.

How can I set nvm remember this different version for a certain project(folder)?

like image 333
Nihal Razak Avatar asked Feb 04 '20 06:02

Nihal Razak


People also ask

How do I use different node versions in NVM?

Switching among Node. 7; we can simply run either nvm use 12.22. 7 or nvm use 16.13. 0 to easily switch into either version we need. Note that since we only have one version that begins with 12, 14, or 16, we can switch versions with a simple nvm use 16 , nvm use 14 , or nvm use 12 command.

Can I use a different node version for project?

Node Version Manager (NVM) is a great tool and easy to switch between multiple node versions while working on projects that required different NodeJs versions. It saves a lot of development time by just switching to the version of nodejs needed.

How do I change the node version in a project?

To change Node. JS versions, we have to first download the version we want. Make sure you have nvm installed first. If you don't know the version you want to install, type nvm ls-remote to get a full list of all installable Node.


1 Answers

You can use an .nvmrc file in the root of the project with the version you want to use. For example v12.4.0 or v10.16.0. You have to make sure that this version is installed or it will use the default node version in your machine.

like image 186
DSCH Avatar answered Oct 03 '22 23:10

DSCH