JavaScript, node.js versions with nvm

TLDR: use nvm to manage node.js versions; develop and deploy with the same version.

$ nvm ls-remote|tail to see the latest versions

$ nvm ls-remote|grep LTS to see the “long term support” versions

$ nvm install lts/erbium to install “erbium” (the latest release of version 12)

$ nvm install 14 to install the latest version 14.x.x release

Version of JavaScript/node

JavaScript and node generally follow the “ECMAScript” standard. There are different implementations of node and JavaScript with their various bugs and optimizations every new version tries to move closer to the standard.

Server-side node.js

You always want to develop your server side projects and deploy your project with the same version of node. Hopefully this is intrinsically clear why. Imagine you develop in node version 14 with let support BUT you deploy in version 4 without let, destructuring , rest parameters or any of the nice features your code uses.

On the server, you have complete control of your deployment node version. On the client, you have no control of the browser JavaScript version. Every version of node updates the language features.

Note: Some features actually get deprecated, while some (tail recursion) don’t exist for any version.

Which version should I use?

Previously, this was a huge deal since each version brought HUGE changes. Nowadays, using the LTS version gets you many of the features you need or learn about.

The node release calendar will let your know the “LTS” (long term support) versions. If you want to build in a corporate production setting, you adopt this version. Make sure to check your deployment service – here is the info for Heroku.

However, if you are developing and exploring you can adopt the latest versions to take advantage of new features. Version 14 has the usual performance updates and additional features like “Optional Chaining” and “Nullish Coalescing”.

Client-side JavaScript

This is a rejection of your browser version.

Older browsers were very far from the standard and that caused a lot of unpredictable bugs – you often saw these “please upgrade your browser” pages. If you work on the web and never had to build these “deprecating IE 8” pages, you must take a deep breath and be grateful.

If you are using a modern web-framework like a batteries included react (next.js, nuxt.js), this will likely be taken care of for you. If you are going vanilla, you will need to polyfill the advanced features you want to use.

But feel confident that many large companies have already decided not to support the oldest browsers (note still supporting IE) because of the actual usage numbers. Be free.

Leave a Reply

Your email address will not be published. Required fields are marked *