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)?
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.
For example, you want your default node version for this project to be v12.
Open your command line in the project root folder, then run nvm use 12, then run node -v > .nvmrc.
It won't solve your issue completely because you'll anyway have to run nvm use just without the version.
Related
I am using VS-code and current version of node is v16.4.0 Now, I wish to change it to 14.17.5 or 14.17.6 , whatever is stable.
Using Ubuntu 18
(& my npm version is 7.18.1)
VS Code is an editor it has nothing to do with your current node version, maybe there is an extension that does that
If you want to have multiple node versions and switch between them easily you can use nvm
I recently decided to install nvm, and the instructions had me uninstall node. I noticed that if I explicitly tell nvm to use a certain version it uses it from the nvm directory, otherwise it uses my bin/node directory, so I didn't notice a conflict. When I uninstalled node, i needed to specify a version every time I use my terminal which seems like an unnecessary step when I could just leave node installed via brew and use nvm if I need to version control.
Once you install nvm and use Node through it, it does NOT use bin/node, but the version installed with nvm, so your old Node is obsolete.
The main reason they recommend you to uninstall Node is because it could confuse the shell about which Node to use. Of course, you can update your shell config so that it first looks for Node installed from nvm, but that's an unnecessary extra step and your old Node distribution is obsolete on your disk, at best.
So, the best solution is uninstalling the old distribution and install nvm (which by default installs the latest Node in your .nvm folder), and install more versions of Node if necessary.
And regarding this:
i needed to specify a version every time I use my terminal which seems like an unnecessary step
You don't need to, as long as you set the default version (say, 11.15.0) config after installing nvm with the following command:
nvm alias default 11.15.0
I have NVM to manage node versions, and I need to use 6.10 for a current project.
When I node -v in terminal I get, v6.10.3. When I run nvm alias default I get default -> 6.10 (-> v6.10.3). In my IDE, Webstorm, I have my Node interpreter set to 6.10.3, and in my package.json I have:
"engines":{"node":"6.10.3"}
However, in my project itself when I run
console.log(process.version);
I get v4.3.2. What am I doing wrong? How can I switch to 6.10.3 in my actual project?
Thanks!
(nvm maintainer here)
The engines field in package.json is purely advisory, and nvm does not pay attention to it. You can add an .nvmrc file to your project with your desired version number; however, you’ll still need to manually nvm use to activate it (see the project readme for ways to make it auto-use on cd, which is too intrusive to do by default).
I installed Node.js from (https://nodejs.org/dist/latest-v5.x/node-v5.12.0-x64.msi), but the issue is , its showing version v0.12.2 instead of v5.12.0 which is required.
I try to update the node.js 5.2 installer but still showing version v0.12.2.
I have uninstalled Node.js and reinstall node-v5.12.0-x64.msi but still it’s not updated. Due to this am not able to run further commands for Ionic environmental setup.
Open a terminal and type where node
It should point to an old version of node (v0.12.2) still installed on your computer, for example C:\bin\node.
As Node.js is portable, you can have multiple versions on your computer.
If it cannot be uninstalled, simply delete C:\bin\node folder.
Then:
Open Windows System Properties/Advanced system properties
Click on Environment variables and edit PATH variable
Remove inside its value the path of the old version of node (C:\bin\node in our example).
Re-install Node v5.
Close your terminal and open a new one then type where node, it should point to Node.js v5
Most likely, you have an old Node version for x86 platform, and you are installing a newer version for 64 bit. Remove the path to the x86 from the Paths env variable, or move it to after the 64 bit path.
Solution:
List node.js installatios using nvm:
nvm ls
High chance the version you tried to install is also listed
Select the version to use using nvm
nvm use
(Not a direct solution)
You can try to install using nvm
Uninstall nodejs and follow the instruction from https://github.com/coreybutler/nvm-windows
I'm working on two applications. The first one has been migrated to 4.2, the other one still needs to be migrated. So, I'm wondering... is there a way to run two different processes against two diff Node.js binaries? In this case, it would be 4.2 and 0.12.
Yes. If you use nvm (https://github.com/creationix/nvm) you'll be able to do this easily.
Using nvm install both Node.js v4.2 and v0.12:
nvm install 4.2
nvm install 0.12
When you run nvm use <version>, nvm will set the Node.js version to <version> for just that terminal window/tab. So, in one terminal you can run nvm use 4.2 then run your node.js application, and in another terminal window or tab run nvm use 0.12 and run your node.js application that uses v0.12.
If you don't want that terminal window or tab to be scoped to a specific version of Node.js, you can use nvm to just run the server using nvm run <version> <args>. For example:
nvm run 0.12 server.js