Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatically switch to correct version of Node based on project

Tags:

node.js

nvm

Let's say I have 2 projects:

example1: requires node version 0.12.1 example2: requires node version 0.10 

Currently, when I cd into each project, I use nvm use <version> before running the application.

Is there a way with node or nvm, to automatically switch to the needed version of node when I cd into each project?

like image 558
cusejuice Avatar asked Apr 15 '15 14:04

cusejuice


People also ask

How do I change node version automatically?

node-version at the root of your projects specifying the node version required. After installing avn, when you cd into a directory with a . node-version file, avn will automatically detect the change and use your installed version manager to switch to that version of node.

How do I downgrade a node version for a specific project?

How do I downgrade to a lower version of node? For Windows and nvm , the command is: nvm install . After installation, run nvm use to switch to the downgraded version of Node.


1 Answers

Install Automatic Node Version Switching (avn) and add .node-version file that specifies the version you'd like to use with project. It automatically detects and uses it via installed version manager such as nvm and n.

like image 181
ferhat Avatar answered Oct 04 '22 03:10

ferhat