Nodejs appear installed but "--version" is not working. On Ubuntu 20.04 LTS

Solution 1:

the Node version at the default Apt PPA is broken. The package is no longer maintained and hasn't been for a while now. It is stuck at version 10, whereas the current official stable release is 17.X.XX. The version is so old that it will not work (trying to use via command line will just give a version deprecation warning), and the NPM configuration installs in a way that anything installed with npm install xxxxx will not be useable.

My advice is to uninstall via apt remove and reinstall via curl or wget, or else add the NodeSource PPAs to sources.list and install from there. See here.

Be sure to uninstall the Ubuntu Repository package first. Otherwise, the system may give the Apt-installed binary priority.