简单的记录以下 nvm-windows 的安装过程
安装
卸载现存的 node.js
Please note, you need to uninstall any existing versions of node.js before installing NVM for Windows. Also delete any existing nodejs installation directories (e.g., “C:\Program Files\nodejs”) that might remain. NVM’s generated symlink will not overwrite an existing (even empty) installation directory.
这一步就卸载了原来的 11 版的 node.js
卸载现存的 npm
You should also delete the existing npm install location (e.g. “C:\Users\
这一步我把 AppData\Roaming\
下的 npm
和 npm-cache
文件夹都删掉了,以前全局安装的包也就没有了。
安装 nvm-windows
这个选好目录下一步下一步就可以了,360会跳出提示框,直接点击的允许
用法
需要以管理员方式打开 powershell,才能运行 nvm 的命令
NVM for Windows is a command line tool. Simply type nvm
in the console for help. The basic commands are:
nvm arch [32|64]
: Show if node is running in 32 or 64 bit mode. Specify 32 or 64 to override the default architecture.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.nvm list [available]
: List the node.js installations. Typeavailable
at the end to show a list of versions available for download.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.nvm uninstall <version>
: Uninstall a specific version.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>
. For information about usinguse
in a specific directory (or using.nvmrc
), please refer to issue #16.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.nvm node_mirror <node_mirror_url>
: Set the node mirror.People in China can use https://npm.taobao.org/mirrors/node/nvm npm_mirror <npm_mirror_url>
: Set the npm mirror.People in China can use https://npm.taobao.org/mirrors/npm/
已经根据最后两条命令设置了淘宝镜像。
全局包管理
After install, reinstalling global utilities (e.g. gulp) will have to be done for each installed version of node:
1 | nvm use 4.4.0 |
这里每个版本对应的全局包是分开的,比如这个版本安装了 vue,切换版本如果不安装 vue 是没法使用的。