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

树莓派3升级Node.js遇问题:执行指定步骤后存异常

Hey there, let's figure out why your Node.js install on Raspberry Pi shows success messages but isn't working as expected. Here are some targeted troubleshooting steps to resolve this:

Troubleshooting Node.js Installation Issues on Raspberry Pi

First, Verify the Installed Version

Start by checking what version of Node.js and npm your system is actually recognizing—this will tell us if the new install is being picked up:

node -v
npm -v

If the output doesn't show v9.11.1, your system might still be using an old version, or the new install didn't complete properly under the hood.

1. Purge Old Node.js Residues

Old, conflicting Node.js packages often cause this "success but broken" scenario. Let's fully remove any existing installations first:

sudo apt-get purge -y nodejs npm
sudo apt-get autoremove -y --purge
sudo rm -rf /usr/local/bin/node /usr/local/bin/npm /usr/local/lib/node_modules

After cleaning up, re-run your original installation commands:

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

2. Check Your PATH Environment Variable

Sometimes the system doesn't prioritize the newly installed Node.js executable. Check if the nodesource install path (/usr/bin) is in your PATH:

echo $PATH

If /usr/bin isn't listed, temporarily add it with:

export PATH=/usr/bin:$PATH

To make this change permanent, edit your ~/.bashrc file, add the line above, then run source ~/.bashrc to apply it immediately.

3. Validate Installation Integrity

Check if all required files from the nodejs package were installed correctly:

dpkg -L nodejs | grep -E "(node|npm)"

You should see entries like /usr/bin/node and /usr/bin/npm. If any are missing, reinstall the package with the --reinstall flag:

sudo apt-get install --reinstall -y nodejs

4. Test Core Node.js Functionality

Create a simple test script to rule out project-specific issues:
Create a file named test.js with this content:

console.log("Running Node.js version:", process.version);

Run it with:

node test.js

If this outputs the correct version (v9.11.1), Node.js itself is working, and you'll need to look into your project's dependencies or configuration for the issue.


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 08:19:59