Installing the Required Modules
Express framework is required to run this app, to install the express framework, open the command prompt/shell and type the below command. The “–g” option simply means the module will be installed globally so that for each project we don’t need to install express separately.
npm install –g express
npm install nano (To install nano module)
Follow the Below Steps to Setup Our Project
After installing nodejs, execute the following commands in order-
npm install express –g
npm install jade –g
npm install nano
npm link express
npm link jade
node app.js //to run the app
And go to browser (any browser) and type below in address bar http://localhost:3000. And press enter if you get the “welcome to express” page you have success created the basic structure required for this app.
Change or create the createdb.js,index.jade,layout.jade,app.js.You can see the detail code at
In the app.js there is a piece of code you might need to config on your side .
var nano = require('nano')('https://username:firstname.lastname@example.org:443');
/*Specify the database to use, so that we don't have to specify everytime*/
var db = nano.use('yourdb')
You need to enter the correct username,password and your cloudant host address.Also you need to make sure you have create your db before in your hosted cloudant doamin.
After finish your code,you need to create a package.json file to add your node.js dependency.
"start": "node app.js"
Finish all the setting,you can open node.js command in your project folder to use npm install command to install node.js module.After that use node app.js to run your sample.
Open the browser and use localhost:3000 to visit,Here I add Contacts as the sample
You can see the successful info after you submit the contacts info.
You can check the data in the your online Cloudant db.
- name: cludanttest
command: node app.js