All Collections
Node.js Development
Node.js Starter Project
Node.js Starter Project

This repository contains an example application that connects to MongoDB Atlas using the Node.js MongoDB driver.

Richa Deshpande avatar
Written by Richa Deshpande
Updated over a week ago

1. Download the Repository

To get started with this sample project, download this repository to your programming environment. You can clone this project using Git version control:

git clone https://github.com/mongodb-university/atlas_starter_nodejs.git

2. Install Dependencies

Navigate to the directory containing the project in your shell or open it in your preferred IDE.

Then, use the NPM dependency file that we included in the project directory called package.json to download and install your dependencies:

npm install

3. Configure your Atlas Credentials

  1. Open the app.js file.

  2. Search for the variable uri near the top which is assigned placeholder text. Replace the placeholder text with the connection string for your Atlas cluster. Save the changes to your app.js file.

const uri = "<Your Atlas Connection String>";

4. Run the Project

If you are running from the shell, you can run the application from the directory that contains it with the following command:

node app

If you are running it from the IDE, use the appropriate command to run the contents of the app.js file.

  • Click the Run icon, or from the Run menu, choose Start Debugging.

Assuming you have the correct connection string, you have now connected the Node app to your MongoDB Atlas datastore. Have fun modifying the code to experiment with the Node driver and MongoDB!

Did this answer your question?