如何升级node版本?下面本篇文章给大家总结分享详细的升级教程,介绍一下window、mac或linux系统下升级node版本的方法,希望对大家有所帮助!
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.log登录后复制
1、升级方法:以下命令如果提示没权限,请在命令的前面加上sudo
,如sudo npm install n -g
【相关教程推荐:nodejs视频教程】
先清除npm缓存:
npm cache clean -f登录后复制
安装node版本管理工具n
;
npm install n -g登录后复制
查看node 所有版本
npm view node versions登录后复制
升级node版本
# 升级到指定的版本:n 版本号n 16.0.0# 升级到最新的稳定版本n stable# 升级到最新版本,不推荐n latest登录后复制
使用node -v查看node版本,如果版本号改变为你想要的则升级成功。
node -v16.0.0登录后复制登录后复制
2、如果版本号没变,可以重启机器或者尝试以下方法
查看通过n安装的node的位置
which node/usr/local/n/versions/node/16.0.0登录后复制
进入该位置
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登录后复制
重新查看版本号
node -v16.0.0登录后复制登录后复制
更多node相关知识,请访问:nodejs 教程!
以上就是如何升级node版本?详细教程分享的详细内容,更多请关注易企推科技其它相关文章!
本文地址:网络百科频道 https://www.eeeoo.cn/wangluo/1150821.html,嗨游网一个专业手游免费下载攻略知识分享平台,本站部分内容来自网络分享,不对内容负责,如有涉及到您的权益,请联系我们删除,谢谢!