Wednesday 5 January 2022

When you need to run "nvm install N/A"...

I noticed in my Terminal (within VSCode) the following:



nvm is Node Version Manager and nvm install installs desired version of Node.

nvm uses the version aliases, some of which are:
  • default - version set to be default in shell
  • node, stable - point to the latest stable version
  • unstable - points to the latest unstable version
  • lts/* - points to the latest long term support line
  • lts/xyz - points to the latest node in xyz line (major release) e.g. erbium, fermium, gallium
 
To Node versions pointed to by aliases, it is possible to use nvm alias command. If alias is pointing to Node version that is not installed locally, N/A is shown:

$ nvm alias 
default -> 11.13.0 (-> N/A)
node -> stable (-> v16.13.1) (default)
stable -> 16.13 (-> v16.13.1) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/gallium (-> v16.13.1)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.7 (-> N/A)
lts/fermium -> v14.18.2 (-> N/A)
lts/gallium -> v16.13.1
 
nvm ls lists all locally installed Node versions, system version of Node, together with aliases.
 
$ nvm ls
       v16.13.1
->       system
default -> 11.13.0 (-> N/A)
node -> stable (-> v16.13.1) (default)
stable -> 16.13 (-> v16.13.1) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/gallium (-> v16.13.1)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.7 (-> N/A)
lts/fermium -> v14.18.2 (-> N/A)
lts/gallium -> v16.13.1

Path to system-installed Node:

$ nvm which system 
/usr/bin/node
 
...and it's version:
 
$ /usr/bin/node --version
v16.13.1
 
In our case  default shell version is set to 11.13.0 which is not installed locally (I might have uninstalled it some time ago). That's why I got this in my Terminal:

N/A: version "N/A -> N/A" is not yet installed.
You need to run "nvm install N/A" to install it before using it.
 

To rectify this, I set default shell version to node:

$ nvm alias default node
default -> node (-> v16.13.1)
 
 
After this, default alias was showing the installed version:

$ nvm ls
->     v16.13.1
         system
default -> node (-> v16.13.1)
node -> stable (-> v16.13.1) (default)
stable -> 16.13 (-> v16.13.1) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/gallium (-> v16.13.1)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.7 (-> N/A)
lts/fermium -> v14.18.2 (-> N/A)
lts/gallium -> v16.13.1

No comments: