Friday, March 14, 2014

Install Express for Node on Raspberry Pi

Express is a web application framework for Node.js. This post show how to install Express on Raspberry Pi, locally in working directory, and generate a app.

Express for node

It's assumed you have installed Node.js on your Raspberry Pi board.

- Make a working directory, for example helloExpress.
$ mkdir helloExpress
$ cd helloExpress

- Install Express locally
$ npm install express

- Because our Express installed locally without path setting, express have to be run with path node_modules/express/bin/express. To create our Hello World, myApp. Run:
$ node_modules/express/bin/express myApp

- Then change to the created directory myApp.
$ cd myApp

- Install with npm
$ npm install

- Run the app:
$ node app

Then you can visit your express web app at port 3000 of your Pi's IP address.


1 comment:

Unknown said...

i have some problem, i wish you can help me. Thanks

this is last progress

pi@raspberrypi:~/myapp $ cd
pi@raspberrypi:~ $ mkdir helloExpress
pi@raspberrypi:~ $ cd helloExpress
pi@raspberrypi:~/helloExpress $ ls
pi@raspberrypi:~/helloExpress $ node --version
v10.8.0
pi@raspberrypi:~/helloExpress $ npm install express
npm WARN cd@1.0.0 No description
npm WARN cd@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"})

+ express@4.16.3
updated 1 package in 30.012s
[+] no known vulnerabilities found [1514 packages audited]

pi@raspberrypi:~/helloExpress $