You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

如何在Raspberry Pi B+上安装Node.js?安装遇阻求教程与解决方案

Fixing Node.js Installation Issues on Raspberry Pi B+

Hey there, I’ve fought through the same Node.js install headaches on a Pi B+ before—let’s get this sorted out for you. The biggest gotcha here is that the Pi B+ uses an ARMv6 architecture, which newer Node.js versions (18+) no longer support. Here’s a step-by-step breakdown that should work reliably:

First: Update Your System (Critical!)

Always start here to avoid dependency conflicts that cause random errors:

sudo apt update && sudo apt upgrade -y

Option 1: Install LTS Node.js 16.x (Last ARMv6-Supported Official Release)

This is the simplest method for most users. Node.js 16.x is the last LTS version that works natively on ARMv6:

  1. Add the NodeSource repository for 16.x:
    curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
    
  2. Install Node.js and npm:
    sudo apt install -y nodejs
    
  3. Verify the install worked:
    node -v && npm -v
    
    You should see version numbers like v16.20.2 and 8.19.4 if it worked.

Option 2: Use nvm (Flexible Version Management)

If you need to switch between Node versions later, nvm is your best bet. It handles architecture compatibility automatically:

  1. Install nvm:
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
    
  2. Restart your terminal, or reload your bash profile to activate nvm:
    source ~/.bashrc
    
  3. Install the latest supported ARMv6 version (we’ll use LTS 16.x here):
    nvm install lts/gallium
    
  4. Set it as your default version:
    nvm alias default lts/gallium
    
  5. Verify:
    node -v && npm -v
    

Fixing Common Errors You Might Hit

  • "Architecture not supported" error: You tried installing a version newer than 16.x. Stick to 16.x or earlier—newer Node builds drop ARMv6 support entirely.
  • npm permission errors: Never use sudo to install npm packages (it causes permission messes). Instead, configure npm to use your user directory:
    mkdir ~/.npm-global
    npm config set prefix '~/.npm-global'
    echo "export PATH=~/.npm-global/bin:$PATH" >> ~/.bashrc
    source ~/.bashrc
    
  • Missing dependencies during install: If you get errors about libssl-dev or build tools, install these first:
    sudo apt install -y build-essential libssl-dev
    

If you’re still hitting specific error messages (like a particular code or warning), drop them in a comment and I’ll help you troubleshoot further!

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

火山引擎 最新活动