GithubHelp home page GithubHelp logo

Comments (4)

mrmodise avatar mrmodise commented on May 26, 2024 1

You need to pass the username and password on the url. mongodb://root:root@localhost:27017/test

from nodejs-ecommerce-store.

datduyng avatar datduyng commented on May 26, 2024 1

Thanks, I realized mongodb://root:root@localhost:27017 works since I didn't create any database name test.

from nodejs-ecommerce-store.

mrmodise avatar mrmodise commented on May 26, 2024

@datduyng it looks like I forgot to include the port on the url. It should be mongodb://localhost:27017/test.

from nodejs-ecommerce-store.

datduyng avatar datduyng commented on May 26, 2024

I am still facing the same error. Please help!

Machine: Window
Node: v15.3.0

Here is my docker-compose file

version: '3.7'
services:
  mongodb_container:
    image: mongo:latest
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: root
    ports:
      - 27017:27017
    networks:
      - etswana-network
    volumes:
      - mongodb_data_container:/data/db

  elasticsearch:
    image: elasticsearch:1.7.5
    container_name: elasticsearch
    ports:
      - 9200:9200
    networks:
       - etswana-network

volumes:
  mongodb_data_container:
networks:
  etswana-network:
    driver: bridge

here are the full error logs

[nodemon] 2.0.2
[nodemon] to restart at any time, enter `rs`
[nodemon] watching dir(s): *.*
[nodemon] watching extensions: js,mjs,json  
[nodemon] starting `node server.js`
(node:2456) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:2456) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
(node:2456) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
(node:2456) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency
(node:2456) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
(node:2456) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Go to http://localhost:3000 in your browser
(node:2456) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead.
Connected to the database
C:\Users\Dat D. Nguyen\Documents\nodejs-ecommerce-store\node_modules\mongodb\lib\cmap\connection.js:261
          callback(new MongoError(document));
                   ^

MongoError: command createIndexes requires authentication
    at MessageStream.messageHandler (C:\Users\Dat D. Nguyen\Documents\nodejs-ecommerce-store\node_modules\mongodb\lib\cmap\connection.js:261:20)
    at MessageStream.emit (node:events:376:20)
    at processIncomingData (C:\Users\Dat D. Nguyen\Documents\nodejs-ecommerce-store\node_modules\mongodb\lib\cmap\message_stream.js:144:12)
    at MessageStream._write (C:\Users\Dat D. Nguyen\Documents\nodejs-ecommerce-store\node_modules\mongodb\lib\cmap\message_stream.js:42:5)
    at writeOrBuffer (node:internal/streams/writable:388:12)
    at MessageStream.Writable.write (node:internal/streams/writable:333:10)
    at Socket.ondata (node:internal/streams/readable:715:22)
    at Socket.emit (node:events:376:20)
    at addChunk (node:internal/streams/readable:304:12)
    at readableAddChunk (node:internal/streams/readable:279:9)
    at Socket.Readable.push (node:internal/streams/readable:218:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:192:23) {
  ok: 0,
  errmsg: 'command createIndexes requires authentication',
  code: 13,
  codeName: 'Unauthorized',
  [Symbol(mongoErrorContextSymbol)]: {}
}
[nodemon] app crashed - waiting for file changes before starting...

from nodejs-ecommerce-store.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.