Difference between revisions of "Node.js on RPi"

From eLinux.org
Jump to: navigation, search
(Created page with "Node.js works on Rapsberry Pi. Currently, it is possible to install Node.js version 0.6 using apt-get. If you want a more recent version, you will need to compile it. == Inst...")
 
("recent" is no more)
 
(7 intermediate revisions by 5 users not shown)
Line 1: Line 1:
Node.js works on Rapsberry Pi.
+
NodeJS maintained builds for RaspberryPi for a while.
Currently, it is possible to install Node.js version 0.6 using apt-get. If you want a more recent version, you will need to compile it.
 
  
== Install Node.js 0.6 ==
+
Though you can install an even older version of Node.js using apt-get,
 +
 
 +
you can also compile the very latest yourself.
 +
 
 +
npm is now installed with nodejs.
 +
 
 +
== Download the most recent arm version of Node.js ==
 +
 
 +
wget '''http://nodejs.org/dist/v0.10.28/node-v0.10.28-linux-arm-pi.tar.gz'''
 +
tar -xzf '''node-v0.10.28-linux-arm-pi.tar.gz'''
 +
node-v0.10.28-linux-arm-pi/bin/node --version
 +
v0.10.28
 +
 
 +
== Install older version Node.js ==
 
Simply call:
 
Simply call:
 
  '''apt-get install nodejs'''
 
  '''apt-get install nodejs'''
  
== Install latest version of Node.js ==
+
== Build latest version of Node.js ==
  
 
Go to Nodejs.org and copy the source code download url.  
 
Go to Nodejs.org and copy the source code download url.  
Line 19: Line 31:
 
  make
 
  make
 
  sudo make install
 
  sudo make install
Node that in your case, you may need to change the bold parts according to the version you want
+
Note that in your case, you may need to change the bold parts according to the version you want
  
The compilation will run for 1 or 2 hours on RPi. If you are doing that using ssh connection, you may want to install '''screen''': It will allow you to close the ssh connection without killing the conpilation process. See http://www.howtoforge.com/linux_screen
+
After that, you can check that Node and NPM are properly installed using the following command lines:
 +
node -v
 +
should reply '''v0.10.2'''
 +
npm -v
 +
should reply '''1.2.25'''
 +
 
 +
The compilation will run for 1 or 2 hours on RPi. If you are doing that using ssh connection, you may want to install '''screen''': It will allow you to close the ssh connection without killing the compilation process. See http://www.howtoforge.com/linux_screen
  
 
Those instructions have been tested with Node.js 0.10.2
 
Those instructions have been tested with Node.js 0.10.2
 +
 +
== See Also ==
 +
* http://www.youtube.com/watch?v=J6g53Hm0rq4 this video is a tutorial to run your first Node.js program (from connecting to your Raspberry Pi to running Node.js)

Latest revision as of 04:59, 30 April 2015

NodeJS maintained builds for RaspberryPi for a while.

Though you can install an even older version of Node.js using apt-get,

you can also compile the very latest yourself.

npm is now installed with nodejs.

Download the most recent arm version of Node.js

wget http://nodejs.org/dist/v0.10.28/node-v0.10.28-linux-arm-pi.tar.gz
tar -xzf node-v0.10.28-linux-arm-pi.tar.gz
node-v0.10.28-linux-arm-pi/bin/node --version
v0.10.28

Install older version Node.js

Simply call:

apt-get install nodejs

Build latest version of Node.js

Go to Nodejs.org and copy the source code download url. In my example: http://nodejs.org/dist/v0.10.2/node-v0.10.2.tar.gz

Create a file called install-node.sh and paste the folloing code:

wget http://nodejs.org/dist/v0.10.2/node-v0.10.2.tar.gz
tar -xzf node-v0.10.2.tar.gz
cd node-v0.10.2
./configure
make
sudo make install

Note that in your case, you may need to change the bold parts according to the version you want

After that, you can check that Node and NPM are properly installed using the following command lines:

node -v

should reply v0.10.2

npm -v

should reply 1.2.25

The compilation will run for 1 or 2 hours on RPi. If you are doing that using ssh connection, you may want to install screen: It will allow you to close the ssh connection without killing the compilation process. See http://www.howtoforge.com/linux_screen

Those instructions have been tested with Node.js 0.10.2

See Also