Running Multiple Node.js Versions in Tandem - node.js

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

Related

Set node version differently for specific project(folder) via 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)?
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.

NodeJS can't install it properly

I had problem with create-react-app and turned out I gotta update my version of nodeJS. The thing is that I can't do so. when I type node --version I get v11.10.0, however when I type sudo n stable, I get:installed : v10.16.3 (with npm 6.9.0).
However when checking version of node I all time get this 11.10.0. How can I get this last stable version 10.16.3?
EDIT: SOLVED
turned out nvm was installed on laptop and it controled node version
I would suggest you use nvm to manage your node versions. It allows you to download multiple versions and you can assign versions on a per project basis. It also allows you to choose which version you want as default
Install nvm it will allow you to install and use any version you want.
Installation steps on ubuntu 18.04

Using nvm for running a single command with different node version

I have node 8 required for my project, but I need to use node 10 for running one of my build command. Is it good to use nvm for running single command with different node version or shall I upgrade my project with higher node version?

Is there a method to use switch to Homebrew version of node when using nvm?

Lots of my packages such as heroku depends on Homebrew’s node, so I have to keep one in the system. I wonder if I can switch between nvm and Homebrew’s node so I don't have to upgrade twice.
For temporary switch, use nvm use system
For every new shell Use nvm alias default system to use brew version.

What are the differences between node.js and node?

I've installed node.js in my machine (linux mint 15), when I run node example.js, it says:
The program 'node' can be found in the following packages:
* node
* nodejs-legacy
Try: sudo apt-get install <selected package>
So what are the differences between node and nodejs? I had both node.js and node installed previously, but when I run node example.js, the web server doesn't start at all. So I deleted node and kept node.js.
The package node is not related to node.js.
nodejs is what you want, however it is arguably better to have the command be called node for compatibility with scripts that use #!/usr/bin/env node.
You can either just create a symlink in your path:
sudo ln -s `which nodejs` /usr/local/bin/node
Or you could install nvm and then use it to install the latest version of node.js:
nvm install stable
I prefer the nvm method, as it allows you to sudo apt-get remove nodejs, and then manage which version of node you're using yourself. You can also have multiple versions of node.js installed and use nvm use <version> to easily switch between them.
I also like to add a line to the bottom my .bashrc like: nvm use stable > /dev/null. That will automatically use the latest version you have installed.
To update your node version to the latest stable: nvm install stable. Every time you do this you will need to install any npm packages that you had installed globally if you want to continue using them.
To switch to an old version just run nvm use <version>, or, if you don't have the old version installed already: nvm install <version>.
This answer is just to tell you the difference between node and nodejs packages on Debian OS.
node
Amateur Packet Radio Node program.
Package details link: https://packages.debian.org/source/wheezy/node
nodejs
Node.js is a platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.
Package details link:
https://packages.debian.org/source/sid/nodejs
There is a simple answer.
Node.JS is the script/code
Node compiles and runs the Node.JS

Resources