What's the best way to use multiple version of node AND npm?

2,005 views
Skip to first unread message

Thomas

unread,
Feb 26, 2012, 12:28:06 PM2/26/12
to nod...@googlegroups.com
Hi,

After installing a bunch of version of node, npm, modules using different ways, I managed to fuck up my installation… I've deleted of files related to node, npm and node modules to start my installation from scratch.

I'm using Mac OS X Lion and reinstalled the official package coming with npm bundled: http://nodejs.org/dist/v0.6.11/node-v0.6.11.pkg (instead of using homebrew's node version like before).

But I also need node 0.4.x for some project running on Heroku. Unfortunately the npm version bundled with node 0.6.11 doesn't work with node 0.4.x. And it seems that `n` and `nave` can manage node versions but not npm versions. How would you do that?

Thanks

Dan North

unread,
Feb 26, 2012, 12:51:47 PM2/26/12
to nod...@googlegroups.com
The nicest way I've found for multiple separate node installs is nodeenv. It works just like Python's virtualenv:

Install a version:
% nodeenv -n 0.6.10 /path/to/node-0.6.10

Use a version:
% source /path/to/node-0.4.6/bin/activate

Now the correct node and npm are in your path. Simples!

To install it just pip install nodeenv (it's a Python script).

Cheers,
Dan
From: Thomas <tbas...@gmail.com>
Date: Sun, 26 Feb 2012 09:28:06 -0800 (PST)
Subject: [nodejs] What's the best way to use multiple version of node AND npm?
--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Shimon Doodkin

unread,
Feb 26, 2012, 5:43:18 PM2/26/12
to nodejs
use issacs nave
then install npm

nave is usually compiles node per user, I do a global install of nave,
like this:

https://github.com/isaacs/nave
curl https://raw.github.com/isaacs/nave/master/nave.sh > /usr/local/
bin/nave
chmod +x /usr/local/bin/nave
mkdir /usr/local/lib/nave
nano /usr/local/bin/nave
add after 1st #! line : NAVE_DIR=/usr/local/lib/nave

make sure you have openssl-dev

nave use 0.6.11

install npm:
curl http://npmjs.org/install.sh | sh


now each time you use node 1st type

nave use 0.6.11

node app.js

in a bash init script:

nave use 0.6.11 /dir/app.js




Shimon Doodkin

On Feb 26, 7:28 pm, Thomas <tbasse...@gmail.com> wrote:
> Hi,
>
> After installing a bunch of version of node, npm, modules using different
> ways, I managed to fuck up my installation… I've deleted of files related
> to node, npm and node modules to start my installation from scratch.
>
> I'm using Mac OS X Lion and reinstalled the official package coming with
> npm bundled:http://nodejs.org/dist/v0.6.11/node-v0.6.11.pkg(instead of

zecho

unread,
Feb 28, 2012, 9:20:54 AM2/28/12
to nodejs
NVM is also an option.

https://github.com/creationix/nvm

On Feb 26, 11:28 am, Thomas <tbasse...@gmail.com> wrote:
> Hi,
>
> After installing a bunch of version of node, npm, modules using different
> ways, I managed to fuck up my installation… I've deleted of files related
> to node, npm and node modules to start my installation from scratch.
>
> I'm using Mac OS X Lion and reinstalled the official package coming with
> npm bundled:http://nodejs.org/dist/v0.6.11/node-v0.6.11.pkg(instead of

Nuno Job

unread,
Feb 28, 2012, 9:36:48 AM2/28/12
to nod...@googlegroups.com
I use nave to manage multiple instances of node, and install everything with npm on 0.6. It never failed me so far but the approach as obvious problems. Most people have a install of npm that works with 0.4 in some folder in their pcs. Then npm link

Nuno

Le Zhang

unread,
Feb 28, 2012, 10:56:35 PM2/28/12
to nod...@googlegroups.com
I'm a fan of N, https://github.com/visionmedia/n

keeps it real simple

Toshihiro Shimizu

unread,
Feb 28, 2012, 11:12:29 PM2/28/12
to nod...@googlegroups.com
I like https://github.com/hokaccha/nodebrew

> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en

--
Toshihiro Shimizu / @meso

Mihai Tomescu

unread,
Feb 29, 2012, 12:44:03 AM2/29/12
to nod...@googlegroups.com
This one is well done https://github.com/creationix/nvm


On Sunday, February 26, 2012 12:28:06 PM UTC-5, Thomas wrote:

Charlie McConnell

unread,
Feb 29, 2012, 12:47:23 AM2/29/12
to nod...@googlegroups.com
I prefer https://github.com/mmalecki/give - it leverages `git archive`, and is very fast at switching (after you've installed the given node version).

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en



--
Charlie McConnell
Head of Support
Nodejitsu, Inc.

Evan

unread,
Feb 29, 2012, 2:32:01 AM2/29/12
to nod...@googlegroups.com
I'm a big fan of NVM as well [[ https://github.com/creationix/nvm ]].  I've used it on OSX and smartOS (open-solaris-ish) without much trouble.
The travis.ci guys use it as well on their VMs to allow you to test your apps against multiple node versions.  

Mark Volkmann

unread,
Feb 29, 2012, 6:56:18 AM2/29/12
to nod...@googlegroups.com
I'll second the vote for n!

---
R. Mark Volkmann
Object Computing, Inc.
--

Le Zhang (@le_isms)

unread,
Feb 29, 2012, 12:01:07 PM2/29/12
to nodejs
Thomas, also see http://devcenter.heroku.com/articles/nodejs-versions

You might not need to switch versions after all

On Feb 26, 12:28 pm, Thomas <tbasse...@gmail.com> wrote:
> Hi,
>
> After installing a bunch of version of node, npm, modules using different
> ways, I managed to fuck up my installation… I've deleted of files related
> to node, npm and node modules to start my installation from scratch.
>
> I'm using Mac OS X Lion and reinstalled the official package coming with
> npm bundled:http://nodejs.org/dist/v0.6.11/node-v0.6.11.pkg(instead of

Tim K

unread,
Jun 7, 2016, 4:42:13 PM6/7/16
to nodejs, tast...@gmail.com
I second nodeenv. It's by far the best thing for system deployments where you may need to run node apps on different node versions simultaneously.
Reply all
Reply to author
Forward
0 new messages