How can I use nvm to manage multiple locally installed node.js?

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

My default profile points to node.js 0.12.7 I have currently installed that PATH points to different versions of node when I start a new terminal.

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

How can I do this without reinstalling node?

+4
source share
2 answers

Reply to original message

For the small amount of data that you saved by doing the following, this is almost not worth it. It is said ...

, nvm:

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

, nvm node:

> which -a node

(.. , node, , ).

, .

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

Node Swapping Made Simple

nvm- node

> 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)

x, x.y x.y.z: nvm install x.y.z. :

> 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

:

> 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 , , node .

#.nvmrc file contents:
5.1.1
+3

nodejs nvm, nvm

node

nvm install 0.12.7

nvm use 0.12.7
0
source

Source: https://habr.com/ru/post/1608751/


All Articles