5

I already have multiple node.js versions installed locally in my x-Linux box, 0.10.40, 0.12.7 and 4.0

My default profile is pointing to node.js 0.12.7 Currently, I set my PATH to point to different versions of node when I start a new terminal.

I would like to use node version manager to use and manage different version of node that is already installed in my environment .

How should I do it without reinstalling node again?

4
  • AFAIK nvm maintains node versions in its own location so it can manage them, so I doubt if you're going to be able to re-use already downloaded versions. But what's the problem--downloading takes a few dozen seconds.
    – user663031
    Commented Sep 24, 2015 at 7:40
  • not possible --see github.com/creationix/nvm/issues/848
    – hohoho
    Commented Sep 24, 2015 at 21:27
  • if each user accounts download their own copies of node, it is duplicating the resources, especially if we have many user account on a machine.
    – hohoho
    Commented Sep 24, 2015 at 21:29
  • If each user accounts download their own copies of node, it is duplicating the resources, especially if we have many user accounts on a machine. The best approach may be for the admin to install nvm on /shared location and install all the node versions using nvm install. Then each account will just do nvm use.
    – hohoho
    Commented Sep 24, 2015 at 21:31

2 Answers 2

5

Answering Original Post

For the small amount of data that you'd save by doing the following, it's almost not worth it. That being said...

Find where current versions are stored in nvm:

> nvm which
# mac
/Users/[username]/.nvm/versions/node/[version]/bin/node
# linux
/home/[username]/.nvm/versions/node/[version]/bin/node

Find all your non-nvm installed versions of node:

> which -a node

(..pending how you are running each of your terminals for each version of node installed will tell how effective this command will be).

Then symbolic link each of them to a folder matching the version.

> ln -s /path/to/node/version ~/.nvm/versions/node/[version]
# `$HOME` or `~/` or `/Home/username/` ... you know which works.

Node and Version Swapping Made Simple

nvm-controlled versions of node installed

> nvm ls
       v0.10.33
       v0.10.36
       v0.10.40
         v4.0.0
         v4.2.2
         v5.0.0
->       v5.1.1
         system
default -> v5.1.1
system -> v5.1.1
node -> stable (-> v5.1.1) (default)
stable -> 5.1 (-> v5.1.1) (default)
iojs -> N/A (default)

Install version x, x.y, or x.y.z: nvm install x.y.z. ie:

> nvm install 4.2.2

# If you want all modules from another version too:
> nvm install 4.2.2 --reinstall-packages-from=0.10.40

Set the default version used:

> nvm use 5.1.1

# But if only a local node command required, use:
# nvm exec [version] [command]
> nvm exec 0.10.33 node server.js

.nvmrc file in project root to define which local version of node to use.

#.nvmrc file contents:
5.1.1
0

You can't using installed nodejs version with nvm, Because nvm use own directory for managing versions

You just need reinstall node versions

nvm install 0.12.7

And then

nvm use 0.12.7
1
  • 1
    Yes, I understand how nvm works. just trying to see if it is possible to fit into our usages. Thanks for your information.
    – hohoho
    Commented Sep 24, 2015 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.