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.

No comments: