• 【node】升级 Node 版本教程


    Window 系统

    PS C:\Users\liuxing> npm install -g n
    npm ERR! code EBADPLATFORM
    npm ERR! notsup Unsupported platform for n@9.0.0: wanted {"os":"!win32","arch":"any"} (current: {"os":"win32","arch":"x64"})
    npm ERR! notsup Valid OS:    !win32
    npm ERR! notsup Valid Arch:  any
    npm ERR! notsup Actual OS:   win32
    npm ERR! notsup Actual Arch: x64
    
    npm 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
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    Mac 或 Linux系统

    • 升级方法:以下命令如果提示没权限,请在命令的前面加上sudo,如sudo npm install n -g
    1. 先清除npm缓存:
    npm cache clean -f
    
    • 1
    1. 安装node版本管理工具n;
    npm install n -g
    
    • 1
    1. 查看node 所有版本
    npm view node versions
    
    • 1

    在这里插入图片描述

    1. 升级node版本
    # 升级到指定的版本:n 版本号
    n 16.0.0
    
    # 升级到最新的稳定版本
    n stable
    
    # 升级到最新版本,不推荐
    n latest 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    1. 使用node -v查看node版本,如果版本号改变为你想要的则升级成功。
    node -v
    16.0.0
    
    • 1
    • 2
    • 如果版本号没变,可以重启机器或者尝试以下方法
    1. 查看通过n安装的node的位置
    which node
    /usr/local/n/versions/node/16.0.0
    
    • 1
    • 2
    1. 进入该位置
    cd /usr/local/n/versions/node
    
    • 1
    1. 编辑/etc/profile
    vim /etc/profile
    
    • 1
    1. 将node安装的路径,添加到文件末尾;
    export NODE_HOME=/usr/local/n/versions/node/16.0.0
    export PATH=$NODE_HOME/bin:$PATH
    
    • 1
    • 2
    1. 输入wq退出保存文件,再编译/etc/profile;
    source /etc/profile
    
    • 1
    1. 重新查看版本号
    node -v
    16.0.0
    
    • 1
    • 2
  • 相关阅读:
    【Python】Pandas(学习笔记)
    Java SE 12 新增特性
    有向图缩点题集
    微信私域运营工具CRM
    H3C构建中小型企业网络(NE)
    Rocky linux8.8系统通过packstack安装OpenStack yoga版本
    【四数之和】
    搭建一个QQ机器人叫女友起床
    微擎模块 微信小程序kǎn jià宝7.2.0开源版
    CyberDAO:web3时代的引领者
  • 原文地址:https://blog.csdn.net/qq_45677671/article/details/127675036