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 jade@1.3.1: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated static-favicon@1.0.2: use serve-favicon module
npm WARN deprecated transformers@2.1.0: Deprecated, use jstransformer
npm WARN deprecated constantinople@2.0.1: Please update to at least constantinople 3.1.1
application-name@0.0.1 /home/user/nodejs/test
├─┬ body-parser@1.0.2 
│ ├── qs@0.6.6 
│ ├─┬ raw-body@1.1.7 
│ │ ├── bytes@1.0.0 
│ │ └── string_decoder@0.10.31 
│ └─┬ type-is@1.1.0 
│   └── mime@1.2.11 
├─┬ cookie-parser@1.0.1 
│ ├── cookie@0.1.0 
│ └── cookie-signature@1.0.3 
├── debug@0.7.4 
├─┬ express@4.0.0 
│ ├─┬ accepts@1.0.0 
│ │ └── negotiator@0.3.0 
│ ├── buffer-crc32@0.2.1 
│ ├── escape-html@1.0.1 
│ ├── fresh@0.2.2 
│ ├── merge-descriptors@0.0.2 
│ ├── methods@0.1.0 
│ ├── parseurl@1.0.1 
│ ├── path-to-regexp@0.1.2 
│ ├── range-parser@1.0.0 
│ ├── send@0.2.0 
│ ├─┬ serve-static@1.0.1 
│ │ └─┬ send@0.1.4 
│ │   ├── fresh@0.2.0 
│ │   └── range-parser@0.0.4 
│ ├── type-is@1.0.0 
│ └── utils-merge@1.0.0 
├─┬ jade@1.3.1 
│ ├── character-parser@1.2.0 
│ ├── commander@2.1.0 
│ ├─┬ constantinople@2.0.1 
│ │ └─┬ uglify-js@2.4.24 
│ │   ├── async@0.2.10 
│ │   ├─┬ source-map@0.1.34 
│ │   │ └── amdefine@1.0.1 
│ │   ├── uglify-to-browserify@1.0.2 
│ │   └─┬ yargs@3.5.4 
│ │     ├── camelcase@1.2.1 
│ │     ├── decamelize@1.2.0 
│ │     ├── window-size@0.1.0 
│ │     └── wordwrap@0.0.2 
│ ├── mkdirp@0.3.5 
│ ├─┬ monocle@1.1.51 
│ │ └─┬ readdirp@0.2.5 
│ │   └─┬ minimatch@3.0.4 
│ │     └─┬ brace-expansion@1.1.11 
│ │       ├── balanced-match@1.0.0 
│ │       └── concat-map@0.0.1 
│ ├─┬ transformers@2.1.0 
│ │ ├─┬ css@1.0.8 
│ │ │ ├── css-parse@1.0.4 
│ │ │ └── css-stringify@1.0.5 
│ │ ├─┬ promise@2.0.0 
│ │ │ └── is-promise@1.0.1 
│ │ └─┬ uglify-js@2.2.5 
│ │   └── optimist@0.3.7 
│ └── with@3.0.1 
├─┬ morgan@1.0.1 
│ └── bytes@0.3.0 
└── static-favicon@1.0.2 

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