• ubuntu安装node.js 2023年最新


    安装说明

    Node.js v18.x
    可以直接粘贴 不用改成具体的版本

    # Using Ubuntu
    curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
    sudo apt-get install -y nodejs
    
    # Using Debian, as root
    curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
    apt-get install -y nodejs
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    Node.js v16.x

    # Using Ubuntu
    curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
    sudo apt-get install -y nodejs
    
    # Using Debian, as root
    curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
    apt-get install -y nodejs
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    Node.js v14.x

    # Using Ubuntu
    curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
    sudo apt-get install -y nodejs
    
    # Using Debian, as root
    curl -fsSL https://deb.nodesource.com/setup_14.x | bash -
    apt-get install -y nodejs
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    Node.js LTS (v16.x)

    # Using Ubuntu
    curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
    sudo apt-get install -y nodejs
    
    # Using Debian, as root
    curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
    apt-get install -y nodejs
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    Node.js当前 (v18.x):

    # Using Ubuntu
    curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
    sudo apt-get install -y nodejs
    
    # Using Debian, as root
    curl -fsSL https://deb.nodesource.com/setup_current.x | bash -
    apt-get install -y nodejs
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    可选:安装构建工具

    要从 npm 编译和安装本机插件,您可能还需要安装构建工具:

    # use `sudo` on Ubuntu or run this as root on debian
    apt-get install -y build-essential
    
    • 1
    • 2

    卸载ubuntu和debian安软件包nodejs

    要完全删除 Node.js请从上面的 deb.nodesource.com 包方法中安装:

    # use `sudo` on Ubuntu or run this as root on debian
    apt-get purge nodejs
    rm -r /etc/apt/sources.list.d/nodesource.list
    
    • 1
    • 2
    • 3

    手动安装

    如果您不是 的粉丝,或者正在使用不受支持的发行版,则可以尝试手动安装。curl | bash -

    这些指令假定存在,但是某些分发版默认情况下不包含此命令,特别是那些专注于最小环境的分发。在这种情况下,您应该安装 或 到 root 以直接运行命令。sudo``sudo``su

    1. 删除旧的 PPA(如果存在)

    仅当您之前使用过 Chris Lea 的节点.js PPA 时,才需要执行此步骤。

    # add-apt-repository may not be present on some Ubuntu releases:
    # sudo apt-get install python-software-properties
    sudo add-apt-repository -y -r ppa:chris-lea/node.js
    sudo rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list
    sudo rm -f /etc/apt/sources.list.d/chris-lea-node_js-*.list.save
    
    • 1
    • 2
    • 3
    • 4
    • 5

    2. 添加节点源包签名密钥

    KEYRING=/usr/share/keyrings/nodesource.gpg
    curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | sudo tee "$KEYRING" >/dev/null
    # wget can also be used:
    # wget --quiet -O - https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | sudo tee "$KEYRING" >/dev/null
    gpg --no-default-keyring --keyring "$KEYRING" --list-keys
    
    • 1
    • 2
    • 3
    • 4
    • 5

    密钥 ID 为 。9FD3B784BC1C6FC31A8A0A1C1655A0AB68576280

    3. 添加所需的节点源存储库

    # Replace with the branch of Node.js or io.js you want to install: node_6.x, node_8.x, etc...
    VERSION=node_8.x
    # Replace with the keyring above, if different
    KEYRING=/usr/share/keyrings/nodesource.gpg
    # The below command will set this correctly, but if lsb_release isn't available, you can set it manually:
    # - For Debian distributions: jessie, sid, etc...
    # - For Ubuntu distributions: xenial, bionic, etc...
    # - For Debian or Ubuntu derived distributions your best option is to use the codename corresponding to the upstream release your distribution is based off. This is an advanced scenario and unsupported if your distribution is not listed as supported per earlier in this README.
    DISTRO="$(lsb_release -s -c)"
    echo "deb [signed-by=$KEYRING] https://deb.nodesource.com/$VERSION $DISTRO main" | sudo tee /etc/apt/sources.list.d/nodesource.list
    echo "deb-src [signed-by=$KEYRING] https://deb.nodesource.com/$VERSION $DISTRO main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    4. 更新软件包列表并安装 Node.js

    sudo apt-get update
    sudo apt-get install nodejs
    
    • 1
    • 2
  • 相关阅读:
    复旦微FMQL20SM全国产ARM+FPGA核心板,替代xilinx ZYNQ7020系列
    Spacewalk
    在公司学习日,学习了结构思考力
    02-MySQL库和表的操作
    java毕业生设计学校食堂订餐管理计算机源码+系统+mysql+调试部署+lw
    【WIFI专题】案例:评估了WIFI模块落板方案,为什么得到的结论是不划算?
    MVVM的构建(java&kotlin)
    我开的游戏经常被攻击该怎么办,云服务器陷入黑洞了要怎么处理,有没有什么好的办法彻底解决攻击
    Springboot通过Filter过滤HttpServletRequest和HttpServletResponse的数据作为日志并通过@Async异步入库
    搜索与图论:染色法判别二分图
  • 原文地址:https://blog.csdn.net/qq_46110497/article/details/126959227