socket.io and pm2 : how does version number in node.js works? - node.js

when I run
node -v
I got 4.2.1 which is very strange since I remember I worked with 0.10 versions: I am totally lost with nodejs versions
reading the pm2 doc
Warning: If you want to use the embedded load balancer (cluster mode),
we recommend the use of node#0.12.0+ or node#0.11.16+. We do not
support node#0.10.*'s cluster module anymore.
I don't understand how node.js versions works: looks like we jumped form 0.10
to 4.2
Does pm2 works with latest version of node.js ?
regards

don't understand how node.js versions works: looks like we jumped form 0.10 to 4.2
When io.js and node.js merged, then node.js jump directly to 4.x series. This happened due to difference in versions of io.js (3.x series) and node.js (0.x series). So next common version was named 4.x series and this lead to some confusion. See this announcement.
Does pm2 works with latest version of node.js ?
You can give it a try yourself, but IMO it should work well.

At the end of 2014, node was forked into io.js for reasons I won't cover here.
The io.js project adopted the semver notation and, as the pace of changes was very fast (we got all the recent advances of ES6 that were already available in V8), came to version 3.
In september 2015, io.js was merged back into node, and it was decided to keep the semver versionning, and to go to version 4. More details here, including the LTS.
This makes it possible to deal with a monotonous version order, thus a 4.0 version of node is greater than a 0.11 version. But be wary, many changes were introduced and the ecosystem is big. You'll probably have changes to do when going from 0.x to a new version, especially if you use many modules.

Related

Downgrade node.js from v7 to v0.10 because of old CentOS

I'm downgrading node.js from v7.7.4 to v0.10.48 because I'm on a CentOS 6.5 server and apparently v0.10.48 is the latest it can handle. Are there issues with going backwards like this?
It should work
There are no issues in way that it will work just as well as it did when it was the current version.
But...
There will be issues with the compatibility of modules on npm. Many of the modules may not work. That is partially because Node v0.10 uses V8 v3.14 (for comparison the current Node versions use V8 v5.x) so a lot of modern JavaScript syntax doesn't work there.
Syntax
For details of what syntax works and what doesn't see:
http://node.green/
For example you will not be able to use a simple arrow functions:
const add1 = x => x + 1;
or even the const keyword for that matter. You will miss a lot of syntax that we now take for granted even on the frontend. Remember that io.js was forked from Node v0.12 mainly because it used such an outdated version of V8 - and it was literally years ago and was about a newer and much modern version than the one you want to use.
Core API
Also the core modules changed during that time changed a lot - compare:
https://nodejs.org/dist/latest-v0.10.x/docs/api/
https://nodejs.org/dist/latest-v7.x/docs/api/
Modules
Because current versions of Node support newer language syntax and have improved core API, a lot of the modules on npm will not work correctly or at all. Make sure that whatever module you use still supports Node v0.10 or use an old version that did support it. You may need to use shrinkwrap to downgrade a lot of sub-dependencies because even if you use an old version of a module that used to work on Node v0.10, it may still load the latest versions of its dependencies that don't work any more.
Security
Also there will be potential issues with bugs and vulnerabilities that will not get fixed. The v0.10 version manitenance ended on 2016-10-31 and the status of this version is currently: End-of-Life. The oldest version that is still maintained today (as of May, 2017) is 4.x.
See:
https://github.com/nodejs/LTS

When is nvm useful given that node.js 6 has good backward compatibility with node.js 4?

NVM (Node version manager) is for managing different versions of node.js. However, since node.js v6 has good backward compatibility with node.js 4, wouldn't it make sense to simply upgrade to v6? Stick to one version. Wouldn't that make life easier? What are some situations when nvm would be useful?
You may have versions in the future that won't be backward compatible, or some of your old client are still running on Node.js version 0.x.x.

How to change or upgrade the version of Node.js and npm in a Meteor app without updating Meteor

Meteor is typically behind in Node.js version because it is a framework that uses its own bundled version of Node.js, and its APIs and features are built to rely on that version of Node.js.
I'm sure that in many cases upgrading Node.js poses no problem.
As an example, Meteor 2.10 at time of writing ships with Node.js 14. But we're already on Node.js 19.
Is there a way to tell Meteor (f.e. with the meteor cli, or some meteor package) to use newer versions of Node.js (and npm)?
Meteor 1.4 now supports Node 4.4.7!
See release notes
To upgrade to Meteor 1.4:
Go to the root of your project's directory
meteor update
Meteor does not support NodeJS 4+ as of now. The discussion is available in https://github.com/meteor/meteor/issues/5124
The latest update to the thread on April 29 is:
Guys, relax. The difference between Node version 4, 5 and 6 are relatively minor, and so if Meteor can support one, it can and will support all others. Ben created PRs for every currently active and supported Node version, but the fundamental part of the work is about making Meteor work with any (recent, non-legacy) Node version, and from there basically everyone should be able to freely select whichever one fits their goals and intentions best (i.e. 4.x if you don't care for bleeding edge Node, 6.x if you do; 5.x is not going to stick around for very long as it's not an LTS version).
So come and check out and help with the PRs if you're interested and
you can, but if not, just rest assured this is being worked on and
prioritized appropriately and I'm pretty sure Ben (and/or others
working on this) will keep everyone posted on any meaningful progress.

why node.js upgrade version 0.12.x directly to 4.0.0?

I guess there maybe some reasons with io.js, but I don't know the history.
Could someone explain this history:
What's the relationship between node.js and io.js?
why node.js doesn't have version 1, 2, but directly release version 4.0.0?
io.js was a fork of node.js. The two projects converged recently.
This discrepancy is explained in many different places on the web, including on the nodejs.org in the news section here. Specifically this part of the announcement:
Named version 4.0.0 because it includes major updates from io.js version 3.0.0

Now that Node.js has added io.js, is it more async than it was before? What's with the version?

I see that Node.js has added i/o to its capabilities, does that mean that it's more async now, or it is using the same concurrency model as before?
Also, I thought Node was on v8, why have they rolled back to v4?
io.js was a fork of the node.js codebase that was advancing differently than the core node.js. io.js was its name and is not directly related to some large set of I/O capabilities.
The version 4.0 nomenclature is derived from the versioning scheme that io.js was using and this is essentially the next major version of that fork. You can read more details in this article: 4.0 is the new 1.0. And, you can read about the merger of the io.js and node.js code bases into the Node Foundation in this article: Node.js and io.js Merge Under the Node Foundation.
All versions of node.js and io.js use the V8 Javascript engine from Google. Those the phrase "V8" implies "version 8", that is not how it is used. "V8" is the name of the Google JS engine and does not change. There is a separate version number for the V8 engine. The 4.0 version number is a node.js version and has nothing to do with which specific version of the V8 JS engine is included.
In this article All you need to know about Node.js 4.0.0, there is this passage which addresses the version number question:
Why “4.0.0”?
The io.js project uses semantic versioning (semver) with its first
major release being a 1.0. The current main line of io.js is 3.x. To
avoid collisions with the 0.x scheme of Node.js it was decided that
the converged version should be a 4.0.0 and will also be following the
semver scheme .. from now on.

Resources