README.md 10.6 KB
Newer Older
C
Corey Butler 已提交
1 2 3 4
[![Tweet This!][1.1] Tweet This!][1]
[1.1]: http://i.imgur.com/wWzX9uB.png (Tweet about NVM for Windows)
[1]: https://twitter.com/intent/tweet?hashtags=nodejs&original_referer=http%3A%2F%2F127.0.0.1%3A91%2F&text=Check%20out%20NVM%20for%20Windows!&tw_p=tweetbutton&url=http%3A%2F%2Fgithub.com%2Fcoreybutler%2Fnvm-windows&via=goldglovecb

C
Corey Butler 已提交
5 6 7 8
## A note on Antivirus

Several users have noticed this app being flagged as a false positive by different antivirus apps like Windows Defender, Kaspersky, MalwareBytes, etc. It turns out these antivirus vendors are flagging the signature of the entire Go programming language.... basically everything written in Go is marked as a virus. See [golang/go#16292](https://github.com/golang/go/issues/16292). Details about how NVM4W is dealing with this are available in [issue #182](https://github.com/coreybutler/nvm-windows/issues/182). 

C
Corey Butler 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
## NOTICE: SEEKING CORE CONTRIBUTORS & MAINTAINERS

_Are you multilingual?_

I am particularly interested in finding people who can speak something other than English. Several problems have come up with non-latin character sets (Chinese, Japanese, Arabic, etc). I am also interested in producing language packs/translations for the installers.

_Are you outside of the US/UK/Canada?_

Custom mirroring capabilities are available in the master branch, but I would like to work with folks in different geographic regions to assure node is accessible everywhere.

_Other (Anywhere)_

The core concepts of this version manager are pretty simple, so the core code base is pretty focused/simple. I've done some work to make this project available on all operating systems. The only reason it's been so slow to release is anticipation of an explosion of new installers (chocolatey, homebrew, rpm, .deb, .msi, etc). I've partnered up with BitRock to simplify creation of some of these, but the BitRock installers don't support all of these.

Of course, I would also love to have additional maintainers. If you're new to Go, that's OK - I was too, and that's what code reviews are for.

C
Corey Butler 已提交
25
# Node Version Manager (nvm) for Windows
C
Corey Butler 已提交
26

C
Corey Butler 已提交
27
[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/coreybutler/nvm-windows?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) (I post development updates here)
T
The Gitter Badger 已提交
28

C
Corey Butler 已提交
29 30
Manage multiple installations of node.js on a Windows computer.

31
**tl;dr** [nvm](https://github.com/creationix/nvm), but for Windows, with an installer. [Download Now](https://github.com/coreybutler/nvm-windows/releases)! This has always been a node version manager, not an io.js manager, so there is no back-support for io.js. However, node 4+ is supported.
C
Corey Butler 已提交
32

C
Corey Butler 已提交
33
![NVM for Windows](http://coreybutler.github.io/nvm-windows/images/installlatest.jpg)
C
Corey Butler 已提交
34 35

There are situations where the ability to switch between different versions of Node.js can be very
C
Corey Butler 已提交
36
useful. For example, if you want to test a module you're developing with the latest
C
Corey Butler 已提交
37 38
bleeding edge version without uninstalling the stable version of node, this utility can help.

C
Corey Butler 已提交
39
![Switch between stable and unstable versions.](http://coreybutler.github.io/nvm-windows/images/use.jpg)
C
Corey Butler 已提交
40

C
Corey Butler 已提交
41
### Installation & Upgrades
C
Corey Butler 已提交
42

C
Corey Butler 已提交
43
It comes with an installer (and uninstaller), because getting it should be easy. Please note, you need to uninstall any existing versions of node.js before installing NVM for Windows.
C
Corey Butler 已提交
44

G
Gwyn Judd 已提交
45 46 47
You should also delete the existing npm install location (e.g. "C:\Users\<user>\AppData\Roaming\npm") so that the nvm install location will be correctly used instead. After install, reinstalling global utilities (e.g. gulp) will have to be done for each installed version of node:

`nvm use 4.4.0`
48
`npm install gulp-cli -g`
G
Gwyn Judd 已提交
49
`nvm use 0.10.33`
50
`npm install gulp-cli -g`
G
Gwyn Judd 已提交
51

C
Corey Butler 已提交
52 53
[Download the latest installer from the releases](https://github.com/coreybutler/nvm/releases).

C
Corey Butler 已提交
54
![NVM for Windows Installer](http://coreybutler.github.io/nvm-windows/images/installer.jpg)
C
Corey Butler 已提交
55

C
Corey Butler 已提交
56
**To upgrade**, run the new installer. It will safely overwrite the files it needs to update without touching your node.js installations.
C
Corey Butler 已提交
57 58
Make sure you use the same installation and symlink folder. If you originally installed to the default locations, you just need to click
"next" on each window until it finishes.
C
Corey Butler 已提交
59 60 61

### Usage

C
Corey Butler 已提交
62
NVM for Windows is a command line tool. Simply type `nvm` in the console for help. The basic commands are:
C
Corey Butler 已提交
63

C
Corey Butler 已提交
64
- `nvm arch [32|64]`: Show if node is running in 32 or 64 bit mode. Specify 32 or 64 to override the default architecture.
C
Corey Butler 已提交
65
- `nvm install <version> [arch]`: The version can be a node.js version or "latest" for the latest stable version. Optionally specify whether to install the 32 or 64 bit version (defaults to system arch). Set `[arch]` to "all" to install 32 AND 64 bit versions.
C
Corey Butler 已提交
66
- `nvm list [available]`: List the node.js installations. Type `available` at the end to show a list of versions available for download.
C
Corey Butler 已提交
67 68 69
- `nvm on`: Enable node.js version management.
- `nvm off`: Disable node.js version management (does not uninstall anything).
- `nvm proxy [url]`: Set a proxy to use for downloads. Leave `[url]` blank to see the current proxy. Set `[url]` to "none" to remove the proxy.
C
Corey Butler 已提交
70
- `nvm uninstall <version>`: Uninstall a specific version.
C
Corey Butler 已提交
71 72 73
- `nvm use <version> [arch]`: Switch to use the specified version. Optionally specify 32/64bit architecture. `nvm use <arch>` will continue using the selected version, but switch to 32/64 bit mode based on the value supplied to `<arch>`.
- `nvm root <path>`: Set the directory where nvm should store different versions of node.js. If `<path>` is not set, the current root will be displayed.
- `nvm version`: Displays the current running version of NVM for Windows.
C
Corey Butler 已提交
74 75 76

### Gotcha!

C
Updated  
Corey Butler 已提交
77
Please note that any global npm modules you may have installed are **not** shared between the various versions of node.js you have installed.
C
Corey Butler 已提交
78
Additionally, some npm modules may not be supported in the version of node you're using, so be aware of your environment as you work.
C
Corey Butler 已提交
79

C
Corey Butler 已提交
80 81
### Antivirus

C
Corey Butler 已提交
82
Users have reported some problems using antivirus, specifically McAffee. It appears the antivirus software is manipulating access to the VBScript engine. See [issue #133](https://github.com/coreybutler/nvm-windows/issues/133) for details and resolution.
C
Corey Butler 已提交
83

C
Corey Butler 已提交
84 85 86 87
---

## Why another version manager?

88
There are several version managers for node.js. Tools like [nvm](https://github.com/creationix/nvm) and [n](https://github.com/tj/n)
C
Corey Butler 已提交
89
only run on Mac OSX and Linux. Windows users are left in the cold? No. [nvmw](https://github.com/hakobera/nvmw) and [nodist](https://github.com/marcelklehr/nodist)
C
Corey Butler 已提交
90 91
are both designed for Windows. So, why another version manager for Windows?

C
Corey Butler 已提交
92 93 94
The architecture of most node version managers for Windows rely on `.bat` files, which do some clever tricks to set or mimic environment variables.
Some of them use node itself (once it's downloaded), which is admirable, but prone to problems. Right around node 0.10.30, the installation
structure changed a little, causing some of these to just stop working with anything new.
C
Corey Butler 已提交
95

C
Corey Butler 已提交
96 97 98 99 100
Additionally, some users struggle to install these modules since it requires a little more knowledge of node's installation structure. I believe if it
were easier for people to switch between versions, people might take the time to test their code on back and future versions... which is
just good practice.

## What's the big difference?
C
Corey Butler 已提交
101

102
First and foremost, this version of nvm has no dependency on node. It's written in [Go](https://golang.org/), which is a much more structured
C
Corey Butler 已提交
103 104 105 106 107 108 109 110 111 112 113
approach than hacking around a limited `.bat` file. It does not rely on having an existing node installation. Plus, should the need arise, Go
offers potential for creating a Mac/Linux version on the same code base with a substanially easier migration path than converting a bunch of
batch to shell logic. `bat > sh, it crazy, right?`

The control mechanism is also quite different. There are two general ways to support multiple node installations with hot switching capabilities.
The first is to modify the system `PATH` any time you switch versions, or bypass it by using a `.bat` file to mimic the node executable and redirect
accordingly. This always seemed a little hackish to me, and there are some quirks as a result of this implementation.

The second option is to use a symlink. This concept requires putting the symlink in the system `PATH`, then updating its target to
the node installation directory you want to use. This is a straightforward approach, and seems to be what people recommend.... until they
realize just how much of a pain symlinks are on Windows. This is why it hasn't happened before.
C
Corey Butler 已提交
114

C
Corey Butler 已提交
115
In order to create/modify a symlink, you must be running as an admin, and you must get around Windows UAC (that annoying prompt). Luckily, this is
116
a challenge I already solved with some helper scripts in [node-windows](https://github.com/coreybutler/node-windows). As a result, NVM for Windows
C
Corey Butler 已提交
117 118 119 120
maintains a single symlink that is put in the system `PATH` during installation only. Switching to different versions of node is a matter of
switching the symlink target. As a result, this utility does **not** require you to run `nvm use x.x.x` every time you open a console window.
When you _do_ run `nvm use x.x.x`, the active version of node is automatically updated across all open console windows. It also persists
between system reboots, so you only need to use nvm when you want to make a change.
C
Corey Butler 已提交
121

C
Corey Butler 已提交
122
NVM for Windows comes with an installer, courtesy of a byproduct of my work on [Fenix Web Server](http://fenixwebserver.com).
C
Corey Butler 已提交
123

C
Updated  
Corey Butler 已提交
124
Overall, this project brings together some ideas, a few battle-hardened pieces of other modules, and support for newer versions of node.
C
Corey Butler 已提交
125

126
I also wrote a simple [data feed](https://github.com/coreybutler/nodedistro) containing a list of node.js versions and their associated npm version.
C
Corey Butler 已提交
127 128
This is how NVM for Windows recognizes the "latest" stable version. It's free for anyone to use.

C
Updated  
Corey Butler 已提交
129
## Motivation
C
Corey Butler 已提交
130

131
I needed it, plain and simple. Additionally, it's apparent that [support for multiple versions](https://github.com/nodejs/node-v0.x-archive/issues/8075) is not
C
Updated  
Corey Butler 已提交
132
coming to node core, or even something they care about. It was also an excuse to play with Go.
C
Corey Butler 已提交
133 134 135

## License

C
Corey Butler 已提交
136
MIT.
C
Corey Butler 已提交
137 138 139

## Thanks

C
Corey Butler 已提交
140
Thanks to everyone who has submitted issues on and off Github, made suggestions, and generally helped make this a better project. Special thanks to [@vkbansal](https://github.com/vkbansal), who has actively provided feedback throughout the releases. Thanks also go to [@rainabba](https://github.com/rainabba) and [@sullivanpt](https://github.com/sullivanpt) for getting Node v4 support integrated.
C
Corey Butler 已提交
141 142 143 144 145 146 147

## Alternatives

- [nvmw](https://github.com/hakobera/nvmw) - Windows Only
- [nodist](https://github.com/marcelklehr/nodist) - Windows Only
- [nvm](https://github.com/creationix/nvm) - Mac/Linux Only
- [n](https://github.com/visionmedia/n) - Mac/Linux Only