Can not switch Node.js to a default version of my choice

When I run nvm alias default 12.8.0 I get this:

default -> 12.8.0 (-> v12.8.0)

But when I run node -v, I get v11.9.0 instead

Why is this happening ?


You have the Node.js snap package installed. The Node.js snap package is started with the node command. Users can choose from one or more of the currently supported releases and get regular automatic updates directly from NodeSource. Node.js versions 6, 8, 9, 10, 11, 13, 14, 15, 16, 17 and 18 are currently available, with the Snap Store being updated within hours or minutes of a Node.js release.

Users can switch between versions of Node.js at any time without needing to involve additional tools like nvm (Node Version Manager), for example:

sudo snap refresh node --channel=8/stable  

Users can also switch from the stable channel to the edge channel with the following command:

sudo snap switch node --edge

Then run node -v to show the currently selected node version.

Node.js LTS schedule

Release Status Codename Initial release LTS Start Maintenance Start Maintenance End
6.x EOL Boron 2016-04-26 2016-10-18 2018-04-30 2019-04-30
7.x EOL 2017-05-30 2017-06-30
8.x EOL Carbon 2016-10-25 2017-10-31 2019-01-01 2019-12-31
9.x EOL 2017-10-01 2018-06-30
10.x EOL Dubnium 2018-04-24 2018-10-30 2020-05-19 2021-04-30
11.x EOL 2018-10-23 2019-06-01
12.x Maintenance LTS Erbium 2019-04-23 2019-10-21 2020-11-301 2022-04-30
13.x EOL 2019-10-22 2020-06-01
14.x Maintenance LTS Fermium 2020-04-21 2020-10-27 2021-10-30 2023-04-30
16.x Active LTS Gallium 2021-04-20 2021-10-26 2022-10-18 2024-04-30
17.x Current 2021-10-19 2022-04-01 2022-06-01
18.x Pending 2022-04-19 2022-10-25 2023-10-18 2025-04-30

I googled everywhere but it seems the command above should work.

Out of curiosity, I tried nvm alias default 12.8 instead of nvm alias default 12.8.0 and that solved my problem.

I could guess this is true only if the last digit is 0, otherwise the the full Node.js version should be written.

I faced this problem when I installed a fresh Nuxt.js application and opted to use Eslint which complained about my Node.js version in use, so I had to upgrade and switch to a newer version.