1
votes

I'm new to GitHub Actions (and continuous integration in general). I was just reading Using Node.js with GitHub Actions and I found this snippet there from the Node.js workflow template:

    strategy:
      matrix:
        node-version: [8.x, 10.x, 12.x]

It's mentioned that

The template includes a matrix strategy that builds and tests your code with three Node.js versions: 8.x, 10.x, and 12.x. The 'x' is a wildcard character that matches the latest minor and patch release available for a version. Each version of Node.js specified in the node-version array creates a job that runs the same steps.

My question is — why build and test with different Node versions? Why not just use one version?

Thank you!

2
What has the title got to do with the actual question? The question seems unclear, please edit it and add in more details. - Daemon Beast
Didn't notice that 🤦🏾‍♂️. Thank you - Mubaraq Wahab
excellent question - rednoyz

2 Answers

4
votes

Node.js versions 8, 10 and 12 are commonly used versions of Node.js. Versions 9 and 11 are considered experimental, since they are odd numbers, and therefore do not get LTS (Long Term Support). On the other hand, versions 8, 10 and 12 are stable.

Firebase cloud functions require either Node.js version 8 or 10, showing that versions 8 and 10 are still quite widely used.

Node.js version 14 was released a few months ago, but I doubt people will move to it until a while later when most of the bugs have been fixed, so it is not entirely necessary to test it, but you can if you want.


As you can see, Node.js versions 8, 10 and 12 are the most widely used versions of Node.js and therefore, it would be a good idea to make sure that your JavaScript code works with those 3 versions to ensure a lot of people can use your code.

If you want to ensure complete compatibility, you can test with even more versions of Node.js, but I doubt you would need to, as Node.js is usually quite backwards-compatible.

If you want to see which versions of Node.js are currently being supported, visit the Node.js releases page.

0
votes

This relates to the important question of "How to build and test with different versions of node?". For example, I have package dependencies that will not build with earlier versions of node (antlr4 being one example), yet I still need to test the distributed code on older versions. This seems to be impossible as things stand (to build with, for example, node 14.x, and test the built code with node 12.x) ?

(though this was not the poster's concern)