Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to install NVM when I already have installed nodejs 8 on Ubuntu?

I have installed nodejs 8, I can't run karma tests with angular 1.. As specified on Karma official website Note: Karma currently works on Node.js 0.10, 0.12.x, 4.x, 5.x, 6.x, and 7.x. See FAQ for more info., I guess problem might be in my node version, they recommend to install node via NVM but I already have installed node 8.. is it possible to install nvm and include there my current nodejs?

like image 421
Arkadi Avatar asked Aug 01 '17 13:08

Arkadi


People also ask

Can I install NVM if I already have Node installed?

You can install and use NVM regardless of whether you have installed Node already. NVM alters path variables to select different versions of Node, so it works with pre-existing installations. Install NVM using either curl or wget .

Can we have 2 versions of Node installed?

NVM allows installing multiple node js versions on the same machine and switching between the required node js version.

Should you install Node before NVM?

Note: We do not recommend using nvm to install Node.js for production environments. If you're installing Node.js on your production environment you should consider using your OS's package manager, or your server tooling of choice, to install and lock the environment to a specific version of Node.js.

How do I install another version of Node using NVM?

To install the LTS version of Node, run nvm install lts . To install a specific version of Node, you need to run nvm list available first so you can see the versions of Node that are available. To install that specific version, run nvm install node-version-number . For example, nvm install 14.20.


1 Answers

Q: Can I still install nvm when I already got an existing node installation?

A: Yes. nvm operates by altering your PATH environment variable to determine the node version your current shell session uses.

For instance when doing nvm use 6.10.3, you immediately can see that $PATH is set to;

PATH=/home/samuelt/.nvm/versions/node/v6.10.3/bin

which node resolves to

/home/samuelt/.nvm/versions/node/v6.10.3/bin/node

Since nvm always try to set the path of its node installation as the first occurrences in PATH even if you have 10 other node installation paths in PATH, the rest will be ignored once the system has found the node binary.

Q: Can I include my installed copy of Node as part of the installed node in nvm?

A: In theory it is possible. But I will say no. To install a particular node version in nvm you'll can do nvm install <version>

like image 155
Samuel Toh Avatar answered Sep 28 '22 15:09

Samuel Toh