AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 412984
Accepted
Username
Username
Asked: 2017-12-26 09:00:09 +0800 CST2017-12-26 09:00:09 +0800 CST 2017-12-26 09:00:09 +0800 CST

无法在 Debian Stretch 上安装最新的 NodeJS

  • 772

我运行 Debian 9.3。我去NodeJS网站查看如何在我的机器上安装 NodeJS v9.X 并运行提供的代码。

curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
sudo apt-get install -y nodejs

但是终端吐出了这条消息:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
nodejs is already the newest version (4.8.2~dfsg-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

我的机器被 NodeJS v4.8.2 和 NPM v1.4.21 卡住了。

如何升级到最新的 NodeJS 和 NPM?

更新

我遵循@GAD3R 的指示。它仍然安装 v4.8.2。这是我在运行 GAD3R 的命令然后运行sudo apt install nodejs​​.

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libuv1
The following NEW packages will be installed:
  libuv1 nodejs
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/3,524 kB of archives.
After this operation, 14.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Selecting previously unselected package libuv1:amd64.
(Reading database ... 141225 files and directories currently installed.)
Preparing to unpack .../libuv1_1.9.1-3_amd64.deb ...
Unpacking libuv1:amd64 (1.9.1-3) ...
Selecting previously unselected package nodejs.
Preparing to unpack .../nodejs_4.8.2~dfsg-1_amd64.deb ...
Unpacking nodejs (4.8.2~dfsg-1) ...
Setting up libuv1:amd64 (1.9.1-3) ...
Processing triggers for libc-bin (2.24-11+deb9u1) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up nodejs (4.8.2~dfsg-1) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode

当我运行update-alternatives --config nodejs时,终端打印update-alternatives: error: no alternatives for nodejs

==

当我跑步时apt-cache policy nodejs,我得到这个......

nodejs:
  Installed: 4.8.2~dfsg-1
  Candidate: 4.8.2~dfsg-1
  Version table:
     9.3.0-1nodesource1 500
        500 https://deb.nodesource.com/node_9.x stretch/main amd64 Packages
     8.9.3~dfsg-2 1
          1 http://ftp.us.debian.org/debian experimental/main amd64 Packages
     6.12.0~dfsg-2 500
        500 http://ftp.us.debian.org/debian unstable/main amd64 Packages
 *** 4.8.2~dfsg-1 990
        990 http://ftp.us.debian.org/debian stretch/main amd64 Packages
        100 /var/lib/dpkg/status

==

我跑了sudo /etc/apt/preferences,直到现在才存在,并在里面写了这个:

Package: *
Pin: release n=experimental
Pin-Priority: 100

Package: *
Pin: release n=unstable
Pin-Priority: 100

Package: *
Pin: release n=stable
Pin-Priority: 500

我重新运行了 GAD3R 帖子中的命令,但 Debian 仍然安装了 v4.8.2nodejs包。

debian node.js
  • 2 2 个回答
  • 4631 Views

2 个回答

  • Voted
  1. Best Answer
    GAD3R
    2017-12-26T09:16:21+08:002017-12-26T09:16:21+08:00

    4.8.2 版本是通过apt从main repo安装的。

    跑:

    apt purge nodejs
    apt install lsb-release
    apt install -y nodejs
    

    验证安装的nodjs版本:

    node --version
    v9.3.0
    

    npm版本:

    npm --version
    5.5.1
    

    问题出在 pin 优先级,将稳定版本 pin 到500

    Package: *
    Pin: release n=experimental 
    Pin-Priority: 100
    

    不稳定:

    Package: *
    Pin: release n=unstable
    Pin-Priority: 100
    

    和马厩:

    Package: *
    Pin: release n=stable
    Pin-Priority: 500
    

    问题通过以下方式解决:

    打开 synaptic ,搜索 nodejs ,按 CTRL + E 然后选择nodsource1版本然后应用更改。

    • 3
  2. Joeri Jongbloets
    2018-09-03T22:26:06+08:002018-09-03T22:26:06+08:00

    我在 Pi3 Model B(使用 raspbian 拉伸 9.4)上遇到了同样的问题。首先,我尝试通过在 apt-get 命令中指定版本来强制安装 nodejs-v8 apt install nodejs=8.11.2~dfsg-1+b1:. 这对我不起作用,因为它导致了未满足的依赖关系:

    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages have not yet been created
    or been moved out of Incoming.
    The following information may help to resolve the situation:
    
    The following packages have unmet dependencies:
    nodejs : Depends: libnghttp2-14 (>= 1.25.0) but 1.18.1-1 is to be installed
             Depends: libuv1 (>= 1.18.0) but 1.9.1-3 is to be installed
             Recommends: nodejs-doc but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.
    

    GAD3R 接受的答案也对我不起作用。

    但是,当我跑步时,apt-cache policy nodejs我得到了这个:

    nodejs:
      Installed: 4.8.2~dfsg-1
      Candidate: 4.8.2~dfsg-1
      Version table:
         8.11.4-1nodesource1 500
            500 https://deb.nodesource.com/node_8.x stretch/main armhf Packages
         8.11.2~dfsg-1+b1 750
            750 https://mirror.nl.leaseweb.net/raspbian/raspbian testing/main armhf Packages
     *** 4.8.2~dfsg-1 900
            900 https://mirror.nl.leaseweb.net/raspbian/raspbian stretch/main armhf Packages
            100 /var/lib/dpkg/status
    

    强制从测试存储库安装 nodejs:

    apt-get install nodejs -t testing
    

    这就像一个魅力!

    node -v
    v8.11.2
    
    • 3

相关问题

  • GRUB 配置以识别同一 Linux 发行版的不同桌面环境(安装)

  • astyle 不会更改源文件格式

  • 接收有关全新 Debian 的电子邮件

  • Debian Stretch:libgs_plugin_systemd-updates.so 中的 gnome-software 段错误

  • 如何在拼音输入法中输入ü?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    JSON数组使用jq来bash变量

    • 4 个回答
  • Marko Smith

    日期可以为 GMT 时区格式化当前时间吗?[复制]

    • 2 个回答
  • Marko Smith

    bash + 通过 bash 脚本从文件中读取变量和值

    • 4 个回答
  • Marko Smith

    如何复制目录并在同一命令中重命名它?

    • 4 个回答
  • Marko Smith

    ssh 连接。X11 连接因身份验证错误而被拒绝

    • 3 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Marko Smith

    systemctl 命令在 RHEL 6 中不起作用

    • 3 个回答
  • Marko Smith

    rsync 端口 22 和 873 使用

    • 2 个回答
  • Marko Smith

    以 100% 的利用率捕捉 /dev/loop -- 没有可用空间

    • 1 个回答
  • Marko Smith

    jq 打印子对象中所有的键和值

    • 2 个回答
  • Martin Hope
    EHerman JSON数组使用jq来bash变量 2017-12-31 14:50:58 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST
  • Martin Hope
    Drux 日期可以为 GMT 时区格式化当前时间吗?[复制] 2017-12-26 11:35:07 +0800 CST
  • Martin Hope
    AllisonC 如何复制目录并在同一命令中重命名它? 2017-12-22 05:28:06 +0800 CST
  • Martin Hope
    Steve “root”用户的文件权限如何工作? 2017-12-22 02:46:01 +0800 CST
  • Martin Hope
    Bagas Sanjaya 为什么 Linux 使用 LF 作为换行符? 2017-12-20 05:48:21 +0800 CST
  • Martin Hope
    Cbhihe 将默认编辑器更改为 vim for _ sudo systemctl edit [unit-file] _ 2017-12-03 10:11:38 +0800 CST
  • Martin Hope
    showkey 如何下载软件包而不是使用 apt-get 命令安装它? 2017-12-03 02:15:02 +0800 CST
  • Martin Hope
    youxiao 为什么目录 /home、/usr、/var 等都具有相同的 inode 编号 (2)? 2017-12-02 05:33:41 +0800 CST
  • Martin Hope
    user223600 gpg —list-keys 命令在将私钥导入全新安装后输出 uid [未知] 2017-11-26 18:26:02 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve