Deploy online
Nelisa wants to see her statistics on a web page from her smartphone.
The Heroku deployment process is built on top of git. To deploy there you need to add Heroku as a git remote (so far we’ve been using GitHub as the origin remote). The Heroku documentation will guide you through the required steps.
Please note:
-
You applications
package.jsonfile’sdependenciessections should contain all the modules your application depends on. So that Heroku knows which modules to install. Installing modules usingnpm install --save <module_name>will keep your package.json up to date. -
The
dependenciessection of your application’spackage.jsonfile should contain all the modules your application depends on; Heroku will use it to install your modules. When you’re developing your application, installing modules usingnpm install --save <module_name>. This adds the module(s) to your package.json so that it’s kept up to date. -
Make sure your applications port number is configurable using the
PORTenvironment variable. This enables Heroku to change the PORT number your application is started on:
//set the port number to an existing environment variable PORT or default to 5000
app.set('port', (process.env.PORT || 5000));
//start the app like this:
app.listen(app.get('port'), function() {
console.log('Node app is running on port', app.get('port'));
});
Deploy your Express application online using Heroku.
Learning areas
- Web application deployment using Heroku;
- How to deploy an existing NodeJS Web App to Heroku.