如何升級(jí)node版本?下面本篇文章給大家總結(jié)分享詳細(xì)的升級(jí)教程,介紹一下Window、Mac或Linux系統(tǒng)下升級(jí)node版本的方法,希望對(duì)大家有所幫助!
PS C:\Users\liuxing> npm install -g nnpm ERR! code EBADPLATFORMnpm ERR! notsup Unsupported platform for n@9.0.0: wanted {"os":"!win32","arch":"any"} (current: {"os":"win32","arch":"x64"})npm ERR! notsup Valid OS: !win32npm ERR! notsup Valid Arch: anynpm ERR! notsup Actual OS: win32npm ERR! notsup Actual Arch: x64npm ERR! A complete log of this run can be found in:npm ERR! C:\Users\liuxing\AppData\Roaming\npm-cache\_logs\2022-11-03T09_24_21_102Z-debug.log1、升級(jí)方法:以下命令如果提示沒(méi)權(quán)限,請(qǐng)?jiān)诿畹那懊婕由?code>sudo,如sudo npm install n -g【相關(guān)教程推薦:nodejs視頻教程】
先清除npm緩存:
(資料圖片)
npm cache clean -f
安裝node版本管理工具n;
npm install n -g
查看node 所有版本
npm view node versions
升級(jí)node版本
# 升級(jí)到指定的版本:n 版本號(hào)n 16.0.0# 升級(jí)到最新的穩(wěn)定版本n stable# 升級(jí)到最新版本,不推薦n latest
使用node -v查看node版本,如果版本號(hào)改變?yōu)槟阆胍膭t升級(jí)成功。
node -v16.0.0
2、如果版本號(hào)沒(méi)變,可以重啟機(jī)器或者嘗試以下方法
查看通過(guò)n安裝的node的位置
which node/usr/local/n/versions/node/16.0.0
進(jìn)入該位置
cd /usr/local/n/versions/node
編輯/etc/profile
vim /etc/profile
將node安裝的路徑,添加到文件末尾;
export NODE_HOME=/usr/local/n/versions/node/16.0.0export PATH=$NODE_HOME/bin:$PATH
輸入wq退出保存文件,再編譯/etc/profile;
source /etc/profile
重新查看版本號(hào)
node -v16.0.0
更多node相關(guān)知識(shí),請(qǐng)?jiān)L問(wèn):nodejs 教程!
以上就是如何升級(jí)node版本?詳細(xì)教程分享的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注php中文網(wǎng)其它相關(guān)文章!
關(guān)鍵詞: