Arun George Arun George - 2 months ago 5x
Node.js Question

app not defined error while deploying through modulus

While trying to deploy my node app using modulus, I encounter

ReferenceError: app is not defined
at Object.<anonymous> (/mnt/app/index.js:1:63)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.runMain (module.js:575:10)
at run (node.js:348:7)
at startup (node.js:140:9)
at node.js:463:3


var express = require('express');
var app = express();

app.get('/hello', function(req, res) {

Express has been installed and added to dependencies in package.json

"dependencies": {
"express": "^4.14.0"

What could be the probable cause for the Error.

app.listen(process.env.PORT || 3000);

Missed out on listening to the environment variable PORT that is causing the issue.