What does body-parser do with express?

To handle HTTP POST requests in Express.js version 4 and above, you need to install the middleware module called body-parser. body-parser extracts the entire body portion of an incoming request stream and exposes it on req.body. The middleware was a part of Express.js earlier but now you have to install it separately. This body-parser module parses the JSON, buffer, string and URL encoded data … Read more

‘node’ is not recognized as an internal or an external command, operable program or batch file while using phonegap/cordova

In Windows, you need to set node.js folder path into system variables or user variables. 1) open Control Panel -> System and Security -> System -> Advanced System Settings -> Environment Variables 2) in “User variables” or “System variables” find variable PATH and add node.js folder path as value. Usually it is C:\Program Files\nodejs;. If variable doesn’t exists, … Read more

NPM clean modules

Is there a way to get npm to unbuild all the modules under node_modules? Something like npm rebuild that removes all build artifacts but doesn’t rebuild them?

What is the difference between __dirname and ./ in node.js?

The gist In Node.js, __dirname is always the directory in which the currently executing script resides (see this). So if you typed __dirname into /d1/d2/myscript.js, the value would be /d1/d2. By contrast, . gives you the directory from which you ran the node command in your terminal window (i.e. your working directory) when you use libraries like path and fs. Technically, it starts out as your working directory … Read more

How do I resolve “Cannot find module” error using Node.js?

Using npm install installs the module into the current directory only (in a subdirectory called node_modules). Is app.js located under home/dave/src/server/? If not and you want to use the module from any directory, you need to install it globally using npm install -g. I usually install most packages locally so that they get checked in along with my project code. … Read more

What is Express.js?

This is over simplifying it, but Express.js is to Node.js what Ruby on Rails or Sinatra is to Ruby. Express 3.x is a light-weight web application framework to help organize your web application into an MVC architecture on the server side. You can use a variety of choices for your templating language (like EJS, Jade, and Dust.js). You can then use a database like MongoDB with Mongoose (for modeling) to provide … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)