Search code examples
javascriptnode.jsangularjsubuntu-16.04upgrade

New version of node.js doesn't show up after installing on Xenial


I seem to have installed a high version of node but it doesn't show up with node -v command.

(base) $ sudo n 10.11.0

  installing : node-v10.11.0
       mkdir : /usr/local/n/versions/node/10.11.0
       fetch : https://nodejs.org/dist/v10.11.0/node-v10.11.0-linux-x64.tar.xz
   installed : v10.11.0 (with npm 6.4.1)

(base) $ node -v
v8.0.0

(base) $ ng
You are running version v8.0.0 of Node.js, which is not supported by Angular CLI 8.0+.
The official Node.js version that is supported is 10.9 or greater.

Please visit https://nodejs.org/en/ to find instructions on how to update Node.js.

Solution

  • From the output shown in the question's body, I noticed sudo n 10.11.0 has installed new version of node in this directory: /usr/local/n/versions/node/10.11.0.

    That path needs to be added to $PATH for bash to find it as follows:

    PATH=/usr/local/n/versions/node/10.11.0/bin/:$PATH

    Add the following export statement to the ~/.bashrc:

    export PATH=/usr/local/n/versions/node/10.11.0/bin/:$PATH

    You need to start a new terminal to see the effects of modifying ~/.bashrc