Home  >  Article  >  Web Front-end  >  How to install NodeJS on Debian Raspberry Pi

How to install NodeJS on Debian Raspberry Pi

巴扎黑
巴扎黑Original
2017-09-20 09:19:402092browse

No special configuration is required to run NodeJS on Raspberry Pi. You just need to ensure that you can use openssh to remotely connect to your Raspberry Pi. About installing NodeJS on Debian (Raspberry Pi) Raspberry Pi You can learn about the method through this article

No special configuration is required to run NodeJS on the Raspberry Pi. You just need to ensure that you can use openssh to remotely connect to your Raspberry Pi.

Install and configure the Open SSH server

This will ensure you can connect to the Raspberry Pi remotely, it should already be installed, but This process ensures the latest version is installed and encryption keys are generated.

If the Raspberry Pi is running in 'headerlesss' mode. If you don't have a monitor, keyboard or mouse, you'll need to connect to the Raspberry Pi via a network cable.


sudo apt-get install openssh-server
sudo rm -rf /etc/ssh/ssh_host_*
sudo dpkg-reconfigure openssh-server

Download Nodejs

Create a new directory to store the downloaded Nodejs file, here We created a 'nodes_download' directory.

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

Not all latest versions of NodeJS can be used on Raspberry Pi. Because some do not specify the ARM instruction set correctly.

Note* The Raspberry Pi uses a CPU with the ARM v7 instruction set.

This article uses the latest compilable version on October 29, 2016.

Use the cd command to jump to the directory where you want to store the downloaded Node.js file. Here we take the Downloads folder as an example, and then download and unzip the 'tar' package:


cd Downloads
wget http://nodejs.org/dist/v6.10.3/node-v6.10.3.tar.gz
tar -xzf node-v6.10.3.tar.gz

Compiling Nodejs

Once the source code download is complete, compilation may take several hours, so please be patient.

Note* The compilation of the previous version only took more than ten minutes, but as the Chriumun V8 engine becomes more and more complex, the compilation time becomes longer and longer, and more and more pairs of pairs should be added. Reasons for ECMAScript 6 support. If you want to improve the compilation speed, you can find the node.js0.x version for compilation.

Install the compilation environment [optional]


apt-get install python g++ make

Use the following command to compile Nodejs:


cd node-v6.10.3
./configure
make

Install the compiled Nodejs code

Once compiled, it can be installed into the Raspberry Pi system. This requires logging into the system using a system administrator, such as the sudo command.


sudo make install

Restart the Raspberry Pi


##

sudo reboot

Check the installation

Once the installation is complete, you can check the version using the following command:


node -v
npm -v

The displayed result should be:

v6.9.1

3.10.8

If the result is normal, the installation of Nodejs and NPM is complete.

Install version 0.12.x of NodeJS

V0.12.x is a very classic version of NodeJS. This version of NodeJS uses ECMAScript 5 The syntax is similar to jQuery version 1.x or Python version 2.7. It does not introduce a series of new syntax features of ES6, such as Class/Promise/Async, etc. Its performance is relatively stable and its size is small. Currently, most npm modules support this node version.

1. You don’t have to enter sudo every time to switch to root. If an error occurs, you may already be an administrator, so you can ignore it.


sudo -s

2. Download and unzip nodejs version 0.12.x


wget http://nodejs.org/dist/v0.12.18/node-v0.12.18.tar.gz
tar -xzf node-v0.12.18.tar.gz

3. Compile


cd node-v0.12.18
./configure
make

4 Installation


make install

The above is the detailed content of How to install NodeJS on Debian Raspberry Pi. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn