Creating an ExpressJS app on a Mac
Step 1
Install Node from http://nodejs.org/
Step 2
This installs ExpressJS command-line tools.
sudo npm install -g express
Step 3
This install tools to help you build an ExpressJS web app quickly.
sudo npm install -g express-generator
Step 4
Create your first ExpressJS app on the desktop.
cd ~/Desktop
express [name of your app]
Step 5
Change directory into your new app
cd ./name/of/your/new/app
Step 6
Install all the necessary packages to formally build an ExpressJS app.
sudo npm install
Step 7
Start your web sever
sudo npm start
Step 8
Confirm the web server is working on your browser
Step 9
Add a listener to the bottom of app.js
app.locals.pretty = true;
// all environments
app.set('port', process.env.PORT || 8080);
/* ** ** ** ** ** ** **
* App Server Listening
* ** ** ** ** ** ** **/
app.listen(app.get('port'), app.get('ipaddress'), function() {
console.log("Node app is running at localhost:" + app.get('port'))
});
Step 10
I generally like to use nodemon
server for development. Here's how to install it for development purposes.
npm install nodemon --save-dev