Install Nodejs on (Raspberry Pi) Raspberry Pi

Source: Internet
Author: User
Tags install node

This article discusses how to install node. js on Raspberry Pi 3 b

Environment description
1. Raspberry Pi installed ' 2016-11-25-raspbian-jessie-lite ' (PS: In this version of the image, SSH is disabled by default, after the image is burned, create a new folder named ' SSH ' in the ' Boot ' partition, boot normally, Connect to Raspberry Pi via SSH)
2. All official software source software has been updated to the latest version.

Goal
Install node.js-6.9.4 on Raspberry Pi 3 B (as of the latest stable version at the time of this release)

Actual combat

After connecting the Raspberry Pi:

Download Nodejs

Note * View the latest version via Http://nodejs.org/dist.

Not all the latest versions of Nodejs can be used on Raspberry Pi. Because some do not correctly specify arm's instruction set.

Note * The Raspberry Pi is using the arm v6 instruction set CPU, but Chriumun V8 the most version of the JavaScript engine, may use some arm v7 functions, such as memory protection.


Download the compiled node. JS for ARM version

1 $ wget https://nodejs.org/dist/latest-v6.x/node-v6.12.2-linux-armv7l.tar.gz

Unzip the file

1 $ tar-xvf node-v6.12.2-linux-armv7l.tar.gz

Verify that node is healthy

$ cd node-v6.12.2-linux-armv7l/bin/$./node-vv6.12.2

Description Normal, PS: Running NPM will receive the following error message:

$./npm-v/usr/bin/env:node:no such file or directory

Don't worry, look down.
Enter the following command in turn:

$ cd ~/$ mv node-v6.12.2-linux-armv7l/usr/local/node$ Echo path= $PATH:/usr/local/node/bin >> ~/.bashrc$ source ~/. Bashrc

Now you can get the current node. js version by entering ' node-v ' under any path.
If the ' npm ' command goes wrong, edit the "/etc/sudoers" file, and the 12-line

Defaults        secure_path= "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

Change to

Defaults       secure_path= "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/node/bin"

Then reboot, enjoy it.

A little explanation

In theory, any Linux system can install node. js in a similar way, and save a lot of time, but note the download of node. js, download node. js in the commands in this article only applies to the ARM v7l platform
Want to know what version of node. js you need to download by command

$ uname-a

To view and display the following information on my Raspberry Pi

Linux raspberrypi 4.4.38-v7+ #938 SMP Thu Dec 15:22:21 GMT armv7l gnu/linux

The following information is displayed on cent OS 6

The following information is displayed on Ubuntu 14.04 LTS Server

Linux host_name 2.6.32-042stab116.2 #1 SMP Fri June 15:33:57 MSK x86_64 x86_64 x86_64 gnu/linux

In the output information can be seen, Raspberry Pi is "ARM v7l", cent OS and Ubuntu is "x86_64" (x86_64 represents 64-bit version, x86 represents 32-bit)
node. js for 64-bit Linux systems

$ wget https://nodejs.org/dist/latest-v6.x/node-v6.9.4-linux-x64.tar.gz

node. js for 32-bit Linux systems

$ wget https://nodejs.org/dist/latest-v6.x/node-v6.9.4-linux-x86.tar.gz

[Refer to link 1: Install node. js on Raspberry Pi 3 B]

[Reference link 2: Install Nodejs on (Raspberry Pi) Raspberry Pi]

Install Nodejs on (Raspberry Pi) Raspberry Pi

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.