How to Run a Web-based Application powered by Express in Node.js

Posted on

The main purpose for writing this article, it is solely to run the web-based application which is powered by express framework. The first step taken is actually to create a web-based application project as shown in the article titled ‘How to Create an Express Web-based Framework Application to be deployed in Node.js’ in this link. To be able to run it, there might be some additional packages or modules to be installed. But before adding modules or packages further, a certain action must be taken for the actual project or folder created can be run in Node.js. It is done by executing a command as shown below :

npm install

The following is the output generated by executing the above command :

user@hostname:~/nodejs/test$ npm install
npm WARN deprecated [email protected]: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated [email protected]: use serve-favicon module
npm WARN deprecated [email protected]: Deprecated, use jstransformer
npm WARN deprecated [email protected]: Please update to at least constantinople 3.1.1
[email protected] /home/user/nodejs/test
├─┬ [email protected] 
│ ├── [email protected] 
│ ├─┬ [email protected] 
│ │ ├── [email protected] 
│ │ └── [email protected] 
│ └─┬ [email protected] 
│   └── [email protected] 
├─┬ [email protected] 
│ ├── [email protected] 
│ └── [email protected] 
├── [email protected] 
├─┬ [email protected] 
│ ├─┬ [email protected] 
│ │ └── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├─┬ [email protected] 
│ │ └─┬ [email protected] 
│ │   ├── [email protected] 
│ │   └── [email protected] 
│ ├── [email protected] 
│ └── [email protected] 
├─┬ [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ ├─┬ [email protected] 
│ │ └─┬ [email protected] 
│ │   ├── [email protected] 
│ │   ├─┬ [email protected] 
│ │   │ └── [email protected] 
│ │   ├── [email protected] 
│ │   └─┬ [email protected] 
│ │     ├── [email protected] 
│ │     ├── [email protected] 
│ │     ├── [email protected] 
│ │     └── [email protected] 
│ ├── [email protected] 
│ ├─┬ [email protected] 
│ │ └─┬ [email protected] 
│ │   └─┬ [email protected] 
│ │     └─┬ [email protected] 
│ │       ├── [email protected] 
│ │       └── [email protected] 
│ ├─┬ [email protected] 
│ │ ├─┬ [email protected] 
│ │ │ ├── [email protected] 
│ │ │ └── [email protected] 
│ │ ├─┬ [email protected] 
│ │ │ └── [email protected] 
│ │ └─┬ [email protected] 
│ │   └── [email protected] 
│ └── [email protected] 
├─┬ [email protected] 
│ └── [email protected] 
└── [email protected] 
user@hostname:~/nodejs/test$

The above command, the ‘npm install’ will install packages or modules specified in the file named ‘package.json’ as the web-based application powered by express framework need those packages or modules as a dependency which must be fulfilled before proceeding on executing the application. Below is the actual output happened upon running the application without executing ‘npm install’ first :

user@hostname:~/nodejs/test$ node app.js 
DEPRECATED use https://github.com/pillarjs/path-to-regexp
module.js:328
    throw err;
    ^
Error: Cannot find module 'static-favicon'
    at Function.Module._resolveFilename (module.js:326:15)
    at Function.Module._load (module.js:277:25)
    at Module.require (module.js:354:17)
    at require (internal/module.js:12:17)
    at Object. (/home/user/nodejs/test/app.js:3:15)
    at Module._compile (module.js:410:26)
    at Object.Module._extensions..js (module.js:417:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:442:10)
user@hostname:~/nodejs/test$

This is the actual output generated after executing ‘npm install’ before running the ‘node js_file_to_be_executed’ :

user@hostname:~/nodejs/test$ node app.js
user@hostname:~/nodejs/test$

The javascript file executed is ‘app.js’ which is the file generated upon creating the web-based application powered by express framework using the command tool express itself. Since there is nothing which can be displayed, there is no output generated. But basically, the application had run successfully without any error message.

Leave a Reply