How to import/use MongoClient from Node.js(React.js) for Atlas?

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Gone away
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Core, Native
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I've setup mongoDB Atlas. mogodb console connection is successful.

      Now, I'm trying to use Node.js(React.js) environment to import and connect to the Atlas.

      First, I installed mongodb driver as below from under my Node.js(React.js) project

      $ npm install mongodb --save

      Second, I imported the MogoClient from within my App.js as below.

      *var MongoClient = require('mongodb').MongoClient; *
      var mongoUrl = 'mongodb://cluster-umtoonist-shared-00-00-di9sq.mongodb.net:27017/mydb';

      Third, I started and compiled App using : "npm start" from console.

      The web page (localhost:3000) is showing the following error (indicating the import failed)

      /Users/goodvibe/node_modules/mongodb-core/lib/topologies/server.js
      Module not found: Can't resolve '../wireprotocol/2_4_support' in '/Users/goodvibe/node_modules/mongodb-core/lib/topologies'

      This is a typical steps to use mongodb as show in the following example :
      https://stackoverflow.com/questions/40725411/advice-needed-how-to-properly-connect-react-to-mongodb

      Q1. Why MongoClient import is failing ? (assuming I can use this same driver to connect to Atlas as long as correct url is provided)

      Q2. Is mogoUrl right format to connect to Atlas DB?

            Assignee:
            Unassigned
            Reporter:
            Dao Circle
            None
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: