windows 安装nvm步骤(shi'yongnvm-windows管理node版本):

前言:mac上可以用n来管理node版本,私以为n很好用。家里的win7台式机一直没有安装过任何管理工具,今天来给家里电脑安装一下nvw-windows,一个用于windows系统的node版本工具。

 

电脑系统:系统win7 64位:

 

nvw-windows的官网:https://github.com/coreybutler/nvm-windows/releases

 

一、安装步骤:

(一)下载:

首先从官网下载安装包 https://github.com/coreybutler/nvm-windows/releases,我下了一个setup版本的,下下来是个压缩包,解压后里面是一个exe,安装方式就如同一个常见的exe安装包,双击运行即可:

 

 

(一)安装:

1.双击exe开始安装:

 

2.下面这一步:配置nvm的安装位置,任意一个你喜欢的位置都可以。

 

3.设置node的symlink文件夹位置。这个文件夹的名字一定不能含有中文或空格!

 

 

 

4.如果在安装nvm之前,电脑上就已经安装有node的,会看到如下图,询问你是否用nvm管理已经存在的node版本。一定要选‘是’,这个弹窗可能会出现好几次,都点是。

5.安装完成。看到如下图:

 

(二)使用nvm:

1.检查nvm是否安装成功:

使用管理员权限打开一个命令行。输入nvm v,会显示nvm的版本号,有则表示安装成功。

2. nvm各命令用法:(黏自官网)

  • 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. Type available 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 using use 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/

 

3. nvm常用命令(个人对上述命令中的常用命令的一个总结和翻译):

  •  安装指定版本的node: nvm install 版本号

    比如安装8.9.3:

nvm install 8.9.3

nvm install node@8.12.0 // 安装8.12.0版本的

node nvm uninstall node@8.12.0 // 卸载node

  • 注意:切换到另一版本后,原来用npm安装的全局依赖在新切换的版本上是用不了的

比如:我在原来的版本用命令npm i -g ionic在全局安装了最新版ionic,切换nodejs版本后用不了,需要重新安装ionic,当然好处是可以安装其他版本的ionic,如npm i -g ionic@1.7.16 1.7.16是ionic1最新版本

  • nvm uninstall 10.6.0卸载指定版本,卸载前最好先切换到其他版本

     

  • 使用nvm查看帮助文档

     

最后

  • 如果你想卸载nvm,请前往控制面板卸载


 

  •  使用指定版本的node: nvm use 版本号

    比如使用8.9.3:

nvm use 8.9.3
  •  使用淘宝node镜像:nvm node_mirror
nvm node_mirror https://npm.taobao.org/mirrors/node/
  • 使用淘宝npm镜像:nvm npm_mirror
nvm npm_mirror https://npm.taobao.org/mirrors/npm/
  • 查看当前电脑上已经安装的全部node版本,正在使用中的版本号前有个星号:
nvm ls
  • 查看可用的(可下载的)全部node版本:
nvm ls available

二、NVM使用中常见错误:

(一)、nvm use  出现exit status 1

(二)、npm都没法自动安装问题解决
目前发现 8.11以上版本的node版本对应的npm都没法自动安装,
需要自己到npm官网( https://npm.taobao.org/mirrors/npm/)
下载手动安装对应的npm版本
1、进入nvm下的指定的node版本目录发现目录下没有npm运行文件
2、进入node_modules发现文件夹为空

3、自己下载node对应的npm版本
4、解压后将文件夹重命名为npm并复制到node_modules目录下
5、最后将npm中bin目录下的npm以及npm.cmd复制到与node_modules目录同级目录下

6、此时npm命令即可使用,如果不能使用需要使用

nvm use node版本号
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值