在树莓派 2 上安装 node.js

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/32563173/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 19:17:27  来源:igfitidea点击:

Installing node.js on raspberry pi 2

node.jsdebianraspbianraspberry-pi2dpkg

提问by slim1801

I have installed Raspbian on my Raspberry Pi 2 and now I am trying to install node.js on it, however I am hitting an issue.

我已经在我的 Raspberry Pi 2 上安装了 Raspbian,现在我正在尝试在其上安装 node.js,但是我遇到了一个问题。

I followed the instructions and typed these commands into the terminal

我按照说明在终端中输入了这些命令

wget http://node-arm.herokuapp.com/node_latest_armhf.deb
sudo dpkg -i node_latest_armhf.deb

But when I check the version of node using

但是当我使用

node -v

I get this error:

我收到此错误:

node: /usr/lib/arm-linux-gnueabihf/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by node)
node: /lib/arm-linus-gnueabihf/libc.so.6: version `GLIBC_2.16' not found (required by node)

I am quite new to using raspberry pi, so any help to fix this issue would be great!

我对使用 raspberry pi 还是很陌生,所以任何解决这个问题的帮助都会很棒!

回答by Irwin

Just putting the response from @Prashant Pathak above here:

只需将@Prashant Pathak 的回复放在这里:

  1. Download latest nodejs build for Raspberry Pi:

    wget https://nodejs.org/download/release/v0.10.0/node-v0.10.0-linux-arm-pi.tar.gz
    
  2. Unpack files in local directory:

    cd /usr/local
    
    sudo tar xzvf ~/node-v0.10.0-linux-arm-pi.tar.gz --strip=1
    
  1. 下载适用于 Raspberry Pi 的最新 nodejs 版本:

    wget https://nodejs.org/download/release/v0.10.0/node-v0.10.0-linux-arm-pi.tar.gz
    
  2. 解压本地目录下的文件:

    cd /usr/local
    
    sudo tar xzvf ~/node-v0.10.0-linux-arm-pi.tar.gz --strip=1
    

That's it. You can confirm it's there by checking the node version with:

就是这样。您可以通过检查节点版本来确认它在那里:

node -v 

and:

和:

npm -v

The actual url to get the files for node will change as the version changes, you can always see the list of files available for download here: http://nodejs.org/download/

获取 node 文件的实际 url 会随着版本的变化而变化,您始终可以在此处查看可供下载的文件列表:http: //nodejs.org/download/

All these instructions came from: http://www.robert-drummond.com/2015/01/08/server-side-javascript-on-a-raspberry-pi-how-to-install-node-js-2/

所有这些说明来自:http: //www.robert-drummond.com/2015/01/08/server-side-javascript-on-a-raspberry-pi-how-to-install-node-js-2/

回答by Prashant Pathak

Alternatively you can upgrade your GCC to V4.8 for this package to work!

或者,您可以将您的 GCC 升级到 V4.8,以便此软件包正常工作!

Option 1 (the better option):

选项 1(更好的选择):

sudo apt-get update
sudo apt-get install gcc-4.8 g++-4.8
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50

Options 2: Upgrade to Debian Jessie

选项 2:升级到 Debian Jessie

Replace all instances of "wheezy" in /etc/apt/sources.list

替换“喘息”中的所有实例 /etc/apt/sources.list

sudo apt-get update
sudo apt-get dist-upgrade

After this you download the Node.js using command line as follows:

在此之后,您使用命令行下载 Node.js,如下所示:

wget http://node-arm.herokuapp.com/node_latest_armhf.deb

Next step is to install the Node.js:

下一步是安装 Node.js:

sudo dpkg -i node_latest_armhf.deb

Finally, you can verify the installation:

最后,您可以验证安装:

node -v

These instructions are mentioned on http://node-arm.herokuapp.com/

http://node-arm.herokuapp.com/上提到了这些说明

回答by Baworaczech

That runs for me: http://blog.wia.io/installing-node-js-v4-0-0-on-a-raspberry-pi/

为我运行:http: //blog.wia.io/installing-node-js-v4-0-0-on-a-raspberry-pi/

Raspberry Pi Model A, B, B+ and Compute Module

Raspberry Pi Model A、B、B+ 和计算模块

wget https://nodejs.org/dist/v4.0.0/node-v4.0.0-linux-armv6l.tar.gz
tar -xvf node-v4.0.0-linux-armv6l.tar.gz
cd node-v4.0.0-linux-armv6l

Raspberry Pi 2 Model B

树莓派 2 B 型

wget https://nodejs.org/dist/v4.0.0/node-v4.0.0-linux-armv7l.tar.gz
tar -xvf node-v4.0.0-linux-armv7l.tar.gz
cd node-v4.0.0-linux-armv7l
sudo cp -R * /usr/local/

回答by Awais Rafique

use nodejs instead of node

使用 nodejs 而不是 node

sudo apt-get update && sudo apt-get install nodejs

须藤 apt-get 更新 && 须藤 apt-get 安装 nodejs

for npm

对于 npm

sudo apt-get install npm

须藤 apt-get 安装 npm

回答by Vikas Putcha

The Latest Node is released for the below platforms, which helped for my old R-PI which is of model name : ARMv6-compatible processor rev 7 (v6l)

为以下平台发布了最新节点,这有助于我的旧 R-PI 模型名称:ARMv6 兼容处理器 rev 7 (v6l)

https://nodejs.org/download/release/v4.1.0/

https://nodejs.org/download/release/v4.1.0/

node-v4.1.0-linux-arm64.tar.gz 17-Sep-2015 04:24 10886090

node-v4.1.0-linux-arm64.tar.gz 2015 年 9 月 17 日 04:24 10886090

node-v4.1.0-linux-arm64.tar.xz 17-Sep-2015 04:24 7100824

node-v4.1.0-linux-arm64.tar.xz 2015 年 9 月 17 日 04:24 7100824

node-v4.1.0-linux-armv6l.tar.gz 17-Sep-2015 17:37 10763504

node-v4.1.0-linux-armv6l.tar.gz 2015 年 9 月 17 日 17:37 10763504

node-v4.1.0-linux-armv6l.tar.xz 18-Sep-2015 00:15 7005048

node-v4.1.0-linux-armv6l.tar.xz 2015 年 9 月 18 日 00:15 7005048

node-v4.1.0-linux-armv7.tar.gz 17-Sep-2015 05:17 10773951

node-v4.1.0-linux-armv7.tar.gz 2015 年 9 月 17 日 05:17 10773951

node-v4.1.0-linux-armv7.tar.xz 17-Sep-2015 05:18 7004760

node-v4.1.0-linux-armv7.tar.xz 2015 年 9 月 17 日 05:18 7004760

node-v4.1.0-linux-armv7l.tar.gz 18-Sep-2015 12:58 10773951

node-v4.1.0-linux-armv7l.tar.gz 2015 年 9 月 18 日 12:58 10773951

回答by Amibest

You can try the following command: wget node-arm.herokuapp.com/node_archive_armhf.deb

您可以尝试以下命令:wget node-arm.herokuapp.com/node_archive_armhf.deb

then sudo dpkg -i node_archive_armhf.deb

然后 sudo dpkg -i node_archive_armhf.deb

node -v should work now!

node -v 现在应该可以工作了!