Nodejs Express Debugging using Visual Studio Code

Click the debugger button located in the left side tool bar

setting debugger

Now you can see the debugger window, Click the setting icon and select Nodejs from the list

setting debugger

It will open (Create) a  launch.json, make sure that the program path locating to your app entry point file ( “program”: “${workspaceRoot}/index.js” ) ( in my case it is index.js in your case may be it is app.js or other). Save the file using Ctrl+S

setting debugger

In the bellow screen you can see the automatically created launch configuration file ‘launch.json’

Open your package.js, check the start script is there or not, if it is not there please add it.

setting debugger

Add break point in your code

setting debugger

Click the debugging button

setting debugger

Open your browser and hit the url

setting debugger



For downloading visual studio code IDE – click here


By bm on August 19, 2016 | Express, NodeJs | A comment?
Tags: , , ,

Nodejs Express GET POST Multipart request handling example

Nodejs Express GET POST Multipart request handling example

Create a new with nodejs and express (check this post for how to create node express project)


  1. create an empty folder in root of your application
  2. install requires node packages (I have added all the node packages in package.json so you can simply run npm install it will take care of this)

index.js this is my app entry point.

routes.js :- I have made a separate rout file that’s why the routs.js file (Check this post for how to make separate rout file) otherwise you can directly add this code into your entry point file (in my case index.js)

I am using the multer node package for handing multipart request



It is ready open your browser and test it


You can see the file is uploaded, but it is using some random name for the file.

For changing file name we can make a small configuration changes in routs.js. Insted of  ‘var upload = multer({ dest: ‘./uploads/’ });’ add the new configuration settings



ref :

Allow CORS in Express/Node.js?

Open index.js (in your case it may be app.js or server.js) and set the request header


By bm on August 17, 2016 | Express, NodeJs | A comment?
Tags: , ,

Nodejs Express separate routes

Move the rout definition from the index.js or app.js

Folder structure

node structure

index.js file



you can add more routs like admin routs (*i am not added this in my project so it will not see int the above folder structure)




By bm on August 2, 2016 | Express, NodeJs | A comment?
Tags: , ,