nvm版本管理工具安裝

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

瞎幾把前言:mac上能夠用n來管理node版本,私覺得n很好用。家裏的win7臺式機一直沒有安裝過任何管理工具,今天來給家裏電腦安裝一下nvw-windows,一個用於windows系統的node版本工具。git

電腦系統:系統win7 64位:github

nvw-windows的官網:https://github.com/coreybutler/nvm-windows/releasesnpm

1、安裝步驟:
(一)下載:
首先從官網下載安裝包 https://github.com/coreybutler/nvm-windows/releases,我下了一個setup版本的,下下來是個壓縮包,解壓后里面是一個exe,安裝方式就如同一個常見的exe安裝包,雙擊運行便可windows

(一)安裝:
1.雙擊exe開始安裝:ide

2.下面這一步:配置nvm的安裝位置,任意一個你喜歡的位置均可以。工具

3.設置node的symlink文件夾位置。這個文件夾的名字必定不能含有中文或空格!測試

4.若是在安裝nvm以前,電腦上就已經安裝有node的,會看到以下圖,詢問你是否用nvm管理已經存在的node版本。必定要選‘是’,這個彈窗可能會出現好幾回,都點是。url

5.安裝完成。看到以下圖:命令行

(二)使用nvm:
1.檢查nvm是否安裝成功:
使用管理員權限打開一個命令行。輸入nvm v,會顯示nvm的版本號,有則表示安裝成功。

  1. 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 [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 : Uninstall a specific version.
    nvm use [arch]: Switch to use the specified version. Optionally specify 32/64bit architecture. nvm use will continue using the selected version, but switch to 32/64 bit mode based on the value supplied to . For information about using use in a specific directory (or using .nvmrc), please refer to issue #16.
    nvm root : Set the directory where nvm should store different versions of node.js. If is not set, the current root will be displayed.
    nvm version: Displays the current running version of NVM for Windows.
    nvm node_mirror : Set the node mirror.People in China can use https://npm.taobao.org/mirrors/node/
    nvm npm_mirror : Set the npm mirror.People in China can use https://npm.taobao.org/mirrors/npm/

  2. nvm經常使用命令(我的對上述命令中的經常使用命令的一個總結和翻譯):
    安裝指定版本的node: nvm install 版本號
        好比安裝8.9.3:

nvm install 8.9.3
使用指定版本的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
2、NVM使用中常見錯誤:
(一)、nvm use 出現exit status 1

使用補充:

一個nodejs的安裝使用流程:

nvm ls // 查看目前已經安裝的版本
nvm install 6.10.0 // 安裝指定的版本的nodejs
nvm use 6.10.0 // 使用指定版本的nodejs
這是我安裝第一個版本時候的命令:

圖6:這是我安裝第一個版本時候的命令

認真看如下的圖,相同的nvm ls命令,獲得的結果爲何不同?由於,這是使用了nvm切換到了指定的版本。若是在nvm ls命令輸出了 當前樣式,說明切換成功了。若是沒有出現(Currently using 64-bit executable),則表示沒有切換成功。這就須要查看緣由,認真按照上面步驟來。
圖7:nvm ls展現已經安裝的nodejs版本

使用命令時注意點
請用管理員身份運行命令管理器,不然可能出錯。
先設置node和npm的淘寶鏡像,這樣成功率和下載速度會更高點。
用途
1:主要用途,切換nodejs版本。若是想使用最新的流行版本測試您正在開發的模塊,而不用卸載穩定版本的node,則可使用nvm來切換nodejs版本。

注意點
nvm安裝目錄,最好不要存在空格。不然,nvm能夠安裝成功,但使用nvm use x.y.z(nodejs的切換)會有問題。
有些全局的npm模塊,可能在各版本的node.js之間不共享。
你正在使用的node.js版本中可能不支持某些npm模塊。所以在工做的時候請注意工做環境。
更多內容請查看:
出處:http://www.cnblogs.com/weiqinl 我的主頁http://weiqinl.com github: weiqinl 簡書:weiqinl

相關文章
相關標籤/搜索