How to connect MongoDB database in a Node.js Applications ?
- First, initialize the node.js project in the particular folder in your machine.
- install the node modules in the project folder
- After this create a connection to the database
Step 1: Create a NodeJS Project and initialize it using the following command:
Step 2: Install the node modules using the following command:
npm i express mongodb mongoose cors
File Structure: Our file structure will look like the following:
Run index.js file using below command:
Please Login to comment...