StephenGrider / Lyrical-GraphQL

Starter project from a GraphQL course on Udemy.com
197 stars 372 forks source link

`open()` is deprecated in mongoose >= 4.11.0 #4

Closed anvlkv closed 4 months ago

anvlkv commented 7 years ago

Hi! Thanks for the Udemy course. There's problem with version of package.



> lyrical@1.0.0 dev /Users/anvlkv/Projects/graphql-course-2
> nodemon index.js --ignore client

[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node index.js`
Listening
(node:41478) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`
Db.prototype.authenticate method will no longer be available in the next major release 3.x as MongoDB 3.6 will only allow auth against users in the admin db and will no longer allow multiple credentials on a socket. Please authenticate using MongoClient.connect with auth credentials.
(node:41478) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): MongoError: Authentication failed.
Error connecting to MongoLab: { MongoError: Authentication failed.
    at Function.MongoError.create (/Users/anvlkv/Projects/graphql-course-2/node_modules/mongoose/node_modules/mongodb-core/lib/error.js:31:11)
    at /Users/anvlkv/Projects/graphql-course-2/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:497:72
    at authenticateStragglers (/Users/anvlkv/Projects/graphql-course-2/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:443:16)
    at Connection.messageHandler (/Users/anvlkv/Projects/graphql-course-2/node_modules/mongoose/node_modules/mongodb-core/lib/connection/pool.js:477:5)
    at Socket.<anonymous> (/Users/anvlkv/Projects/graphql-course-2/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:321:22)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at Socket.Readable.push (_stream_readable.js:134:10)
    at TCP.onread (net.js:548:20)
  name: 'MongoError',
  message: 'Authentication failed.',
  ok: 0,
  code: 18,
  errmsg: 'Authentication failed.' }
Hash: c5c1a61fae5f1dd0af11
Version: webpack 2.6.1
Time: 1863ms
     Asset       Size  Chunks                    Chunk Names
 bundle.js     726 kB       0  [emitted]  [big]  main
index.html  309 bytes          [emitted]         
chunk    {0} bundle.js (main) 704 kB [entry] [rendered]
    [0] ./~/process/browser.js 5.42 kB {0} [built]
    [8] ./~/react-dom/lib/ReactInstrumentation.js 601 bytes {0} [built]
   [10] ./~/react-dom/lib/ReactUpdates.js 9.53 kB {0} [built]
   [15] ./~/react/lib/ReactElement.js 11.2 kB {0} [built]
   [18] ./~/react-dom/lib/ReactReconciler.js 6.21 kB {0} [built]
   [19] ./~/react/lib/React.js 2.69 kB {0} [built]
   [79] ./~/react-dom/index.js 59 bytes {0} [built]
   [80] ./~/react/react.js 56 bytes {0} [built]
   [81] ./client/index.js 498 bytes {0} [built]
  [109] ./~/react-dom/lib/ReactDOM.js 5.14 kB {0} [built]
  [171] ./~/react/lib/ReactDOMFactories.js 5.53 kB {0} [built]
  [172] ./~/react/lib/ReactPropTypes.js 15.8 kB {0} [built]
  [173] ./~/react/lib/ReactPureComponent.js 1.32 kB {0} [built]
  [174] ./~/react/lib/ReactVersion.js 350 bytes {0} [built]
  [176] ./~/react/lib/onlyChild.js 1.34 kB {0} [built]
     + 163 hidden modules
Child html-webpack-plugin for "index.html":
         Asset    Size  Chunks  Chunk Names
    index.html  544 kB       0  
    chunk    {0} index.html 541 kB [entry] [rendered]
        [0] ./~/lodash/lodash.js 540 kB {0} [built]
        [1] ./~/html-webpack-plugin/lib/loader.js!./client/index.html 616 bytes {0} [built]
        [2] (webpack)/buildin/global.js 509 bytes {0} [built]
        [3] (webpack)/buildin/module.js 517 bytes {0} [built]
webpack: Compiled successfully.```
zchebil commented 4 years ago

I had some difficulties installing the repository but I solved these issues and want to share with you how to fix them

//first 👍 git clone the repository then git clone it and fix some issues

git clone https://github.com/StephenGrider/Lyrical-GraphQL cd Lyrical-GraphQL npm i npm audit fix npm audit fix --force

npm install -g webpack@2.2.0 npm install --save-dev webpack@2.2.0

//inside the file server.js put your mongodb URI that you get from mongoDB site //copy your Very OWN MONGO_URI the one below is not real

const MONGO_URI = 'mongodb+srv://:@clust0-l1g02.mongodb.net/test';

//then add {useUnifiedTopology: true, useNewUrlParser: true}

mongoose.connect(MONGO_URI, { useUnifiedTopology: true, useNewUrlParser: true, });