You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Debian 9无法安装最新版本Node.js问题求助

Fixing Node.js Installation Issues on Debian 9

Alright, let's tackle both of your problems here—first that pesky Chrome repo error, then getting the latest Node.js instead of the outdated v4.8.2 that Debian 9's default repo serves up.

1. Fixing the Chrome Repository Fetch Error

That E: Failed to fetch http://dl.google.com/linux/chrome/deb/dists/stable/InRelease error is totally unrelated to your Node.js install—it's just your system trying to pull updates from Google Chrome's repository, which is broken for Debian 9 (since Chrome no longer supports this old release). While it won't interfere with Node.js, it's easy to silence:

  • Open the Chrome repo configuration file:
    sudo nano /etc/apt/sources.list.d/google-chrome.list
    
  • Add a # at the start of every line in this file to comment out the Chrome source. This stops apt from trying to access it.
  • Save and exit nano (press Ctrl+O, hit Enter, then Ctrl+X).
  • Run sudo apt update again, and that Chrome error should be gone.

2. Installing the Latest Node.js (Ditch v4.8.2)

Debian 9's default repositories only include Node.js v4.x, which is way past end-of-life. To get a modern, supported version, you need to use the official Nodesource repository properly. Here's how:

Step 1: Uninstall the old Node.js

First, remove the outdated version to avoid conflicts:

sudo apt remove --purge nodejs npm
sudo apt autoremove

Step 2: Set up the Nodesource repository

Nodesource maintains updated Node.js packages for older Debian releases. Let's add the repo for Node.js 18.x (the last LTS version that supports Debian 9):

  • Import the Nodesource GPG key to verify package authenticity:
    curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/nodesource.gpg
    
  • Add the Node.js repository to your system:
    echo "deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x stretch main" | sudo tee /etc/apt/sources.list.d/nodesource.list
    echo "deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_18.x stretch main" | sudo tee -a /etc/apt/sources.list.d/nodesource.list
    

Step 3: Install the latest Node.js

  • Update your package list:
    sudo apt update
    
  • Install Node.js:
    sudo apt install nodejs
    

Step 4: Verify the installation

  • Check that you have the correct version:
    node -v
    npm -v
    

You should see a version like v18.17.1 (the latest LTS for Node.js 18.x) instead of v4.8.2.


内容的提问来源于stack exchange,提问作者Hamdi Gatri

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 07:20:58