• 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
  • 相关阅读:
    HTB-Buff
    开源啦!一键部署免费使用!Kubernetes上直接运行大数据平台!
    SpringBoot中自动装配机制
    javacc之路0--- 安装与使用
    计算机网络课后作业2023秋
    MySQL数据库八股文
    C++ //练习 15.7 定义一个类使其实现一种数量受限的折扣策略,具体策略是:当购买书籍的数量不超过一个给定的限量时享受折扣,如果购买量一旦超过了限量,则超出的部分将以原价销售。
    SpringBoot+Vue实现前后端分离的员工日志管理信息系统
    灰色预测模型
    CNN 网络结构简介
  • 原文地址:https://blog.csdn.net/qq_46110497/article/details/126959227