nvm: nodejs version manager
npm:nodejs package manager
所有版本下載
https://github.com/coreybutler/nvm-windows/releases
推薦姿勢(shì)
推薦下載nvm-setup不要下載nvm-noinstall
2018-4-8 20:14:28截止目前nvm-setup
nvm-noinstall發(fā)生的問題
nvm-setup1.1.6.zip
是最新的硕盹,另外呢另外一個(gè)nvm-noinstall.zip我嘗試過,下載完成之后打開需要手動(dòng)打開install.cmd
然后還提示權(quán)限不夠熏迹,使用超級(jí)管理員打開之后,成功了司光,但是呢并沒有生成setting.txt我懷疑生成到其他地方去了千埃,暫時(shí)不懂原理鸯旁,是否當(dāng)前目錄可以創(chuàng)建一個(gè)就能優(yōu)先使用這個(gè)。
繼續(xù)
nvm-setup下載之后是一個(gè)exe文件医清,安裝過程中建議手動(dòng)修改一下目錄起暮,避免生成到一些不靠譜的地方。
我這里填寫的地址是
F:\react-native\bin\nvm-noinstall\nvm-setup
這個(gè)目錄下本身就是nvm-setup.exe所在目錄会烙,安裝完成之后在這個(gè)目錄創(chuàng)建了一個(gè)nvm文件夾
F:.
│ nvm-setup.exe
│
└─nvm
elevate.cmd
elevate.vbs
install.cmd
nodejs.ico
nvm.exe
settings.txt
unins000.dat
unins000.exe
F:\react-native\bin\nvm-noinstall\nvm-setup>
settings.txt
文件內(nèi)容:
root: F:\react-native\bin\nvm-noinstall\nvm-setup\nvm
path: D:\Program Files\nodejs
安裝之后環(huán)境變量自動(dòng)配置了,如果之前配置過nvm的則會(huì)覆蓋刪除之前的環(huán)境變量,我之前是手動(dòng)配置的下載的是另外一個(gè)nvm-install包..
測(cè)試:
輸入
nvm root
查看安裝路徑负懦,輸入nvm version
查看nvm版本
C:\Users\Administrator.DESKTOP-Q7DQAHS>nvm root
Current Root: F:\react-native\bin\nvm-noinstall\nvm-setup\nvm
C:\Users\Administrator.DESKTOP-Q7DQAHS>nvm version
1.1.6
可以驗(yàn)證正是我之前填寫的安裝路徑 版本也是正常的筒捺。
代理下載加速
在安裝目錄下的settings.txt
文件中添加如下內(nèi)容
node_mirror: http://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/
下載node.js最新版
首先看看https://nodejs.org/en/ 最新版本是多少
`
截止2018-4-8 20:26:03 目前最新版nodejs是9.11.1
輸入nvm install 9.11.1
C:\Users\Administrator.DESKTOP-Q7DQAHS>nvm install 9.11.1
Downloading node.js version 9.11.1 (64-bit)...
Complete
Creating F:\react-native\bin\nvm-noinstall\nvm-setup\nvm\temp
Downloading npm version 5.6.0... Complete
Installing npm v5.6.0...
Installation complete. If you want to use this version, type
nvm use 9.11.1
有木有發(fā)現(xiàn)自動(dòng)給我下載了一個(gè)npm 5.6.0
什么是npm
npm 是 JavaScript 世界的包管理工具,并且是 Node.js 平臺(tái)的默認(rèn)包管理工
https://www.npmjs.com.cn/
檢查安裝
之前沒有安裝node.js是這樣的
C:\Users\Administrator.DESKTOP-Q7DQAHS>nvm list
No installations recognized.
安裝之后是這樣的
C:\Users\Administrator.DESKTOP-Q7DQAHS>nvm list
9.11.1
檢查node.js環(huán)境變量
C:\Users\Administrator.DESKTOP-Q7DQAHS>node --version
v9.7.1
可以看出來一切ok.
檢查npm包管理器工具是否正常
npm@5.6.0 D:\Program Files\nodejs\node_modules\npm
C:\Users\Administrator.DESKTOP-Q7DQAHS>npm help
Usage: npm <command>
where <command> is one of:
access, adduser, bin, bugs, c, cache, completion, config,
ddp, dedupe, deprecate, dist-tag, docs, doctor, edit,
explore, get, help, help-search, i, init, install,
install-test, it, link, list, ln, login, logout, ls,
outdated, owner, pack, ping, prefix, profile, prune,
publish, rb, rebuild, repo, restart, root, run, run-script,
s, se, search, set, shrinkwrap, star, stars, start, stop, t,
team, test, token, tst, un, uninstall, unpublish, unstar,
up, update, v, version, view, whoami
npm <command> -h quick help on <command>
npm -l display full usage info
npm help <term> search for help on <term>
npm help npm involved overview
Specify configs in the ini-formatted file:
C:\Users\Administrator.DESKTOP-Q7DQAHS\.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config
npm@5.6.0 D:\Program Files\nodejs\node_modules\npm
C:\Users\Administrator.DESKTOP-Q7DQAHS>npm --version
5.6.0
可以看出來安裝目錄也提示出來了D:\Program Files\nodejs\node_modules\npm
。 很ok,是我要的結(jié)果纸厉,給我安裝到d盤了系吭。
直接安裝最新版
npm install latest
下面的意思
F:\react-native\bin\nvm-noinstall\nvm-setup\nvm>nvm install last
last.0.0
Node.js vlast.0.0 is only available in 32-bit.
F:\react-native\bin\nvm-noinstall\nvm-setup\nvm>nvm install latest
Version 9.11.1 is already installed.
F:\react-native\bin\nvm-noinstall\nvm-setup\nvm>nvm install 9.11.0
Downloading node.js version 9.11.0 (64-bit)...
Complete
Creating F:\react-native\bin\nvm-noinstall\nvm-setup\nvm\temp
Downloading npm version 5.6.0...
第一句表示我輸錯(cuò)了,第二句表示我這最新版已經(jīng)下載了颗品, 第三句是下載9.11.0
版本
F:\react-native\bin\nvm-noinstall\nvm-setup\nvm>nvm install 9.11.0
Downloading node.js version 9.11.0 (64-bit)...
Complete
Creating F:\react-native\bin\nvm-noinstall\nvm-setup\nvm\temp
Downloading npm version 5.6.0... Error while downloading https://npm.taobao.org/mirrors/npm/v5.6.0.zip - Get http://172.168.18.18:8084/SXC_B_3512495485_16512182594317269750/cdn.npm.taobao.org/dist/npm/v5.6.0.zip: EOF
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x20 pc=0x5b32f7]
goroutine 1 [running]:
_/C_/Users/Corey/Documents/workspace/OSS/nvm-windows/src/nvm/web.Download(0x10f6a0c0, 0x2d, 0x10eda320, 0x43, 0x10f238d0, 0x5, 0x0)
C:/Users/Corey/Documents/workspace/OSS/nvm-windows/src/nvm/web/web.go:67 +0x307
_/C_/Users/Corey/Documents/workspace/OSS/nvm-windows/src/nvm/web.GetNpm(0x10edc481, 0x2f, 0x10f238d0, 0x5, 0x48)
C:/Users/Corey/Documents/workspace/OSS/nvm-windows/src/nvm/web/web.go:163 +0x21b
main.install(0x10eca0d0, 0x6, 0x642b6f, 0x2)
C:/Users/Corey/Documents/workspace/OSS/nvm-windows/src/nvm.go:260 +0x680
main.main()
C:/Users/Corey/Documents/workspace/OSS/nvm-windows/src/nvm.go:76 +0xa78
F:\react-native\bin\nvm-noinstall\nvm-setup\nvm>nvm list
9.11.1
9.11.0
F:\react-native\bin\nvm-noinstall\nvm-setup\nvm>****
成功下載另外一個(gè)版本9.11.0
而且是從淘寶下載的https://npm.taobao.org/mirrors/npm/v5.6.0.zip
可以看出來
切換node.js版本
F:\react-native\bin\nvm-noinstall\nvm-setup\nvm>nvm use 9.11.1
Now using node v9.11.1 (64-bit)
切換修改需要重新打開命令行.這個(gè)簡單的道理大家都應(yīng)該懂吧.
問題解決
如果執(zhí)行node提示不是可執(zhí)行文件肯尺,或者通過執(zhí)行npm提示這個(gè)node
命令有問題,那就需要通過where npm
找到node**exe
把64這個(gè)字刪掉躯枢,
不過通過輸入
nvm use [version] [arch]
的語法來看则吟,切換辦法的時(shí)候要寫一下架構(gòu)才行,不過我現(xiàn)在是暴力修改了锄蹂。···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).···
為什么要用這個(gè)氓仲?
雙擊
官網(wǎng)的node.js下載下來之后自動(dòng)可以使用npm了,但是會(huì)出現(xiàn)很多問題败匹,目前我出現(xiàn)的問題是一個(gè)普通的 npm install -g hexo-cli
都報(bào)錯(cuò)了寨昙,說語法有問題》