[MONGOOSE] DeprecationWarning: Mongoose: the strictQuery option will be switched back to false by default in Mongoose 7. Use mongoose.set('strictQuery', false); if you want to prepare for this change. Or use mongoose.set('strictQuery', true); to suppress this warning.
(Use node --trace-deprecation ... to show where the warning was created)
Please help me out to get it resolve
Added deprecation warning https://github.com/Automattic/mongoose/pull/12675. Just add mongoose.set before your mongoose.connect to suppress the warning.
mongoose.set('strictQuery', true);
mongoose.connect(// codes)
Related
(node:10348) [MONGOOSE] Deprecation Warning: Mongoose: the `strict Query` option will be switched back to `false` by default in Mongoose 7. Use `mongoose. Set('strict Query', false);` if you want to prepare for this change. Or use `mongoose. Set('strict Query', true);` to suppress this warning.
(Use `node --trace-deprecation ...` to show where the warning was created)
I can't understand so explain.
node "c:\Users\muham\Coading 1\WEB DEVELOPMENT\MERN\SOCIAL-APP\server\index.js"
MongoParseError: Password contains unescaped characters did not connect
(node:7812) [MONGOOSE] DeprecationWarning: Mongoose: the strictQuery option will be switched back to false by default in Mongoose 7. Use mongoose.set('strictQuery', false); if you want to prepare for this change. Or use mongoose.set('strictQuery', true); to suppress this warning.
(Use node --trace-deprecation ... to show where the warning was created)
i had done with every steps ut still it's showing linke this
I migrated my app from angular 10 to 11, and updated to webpack 5 using :
"resolutions": {
"webpack": "^5.0.0"
}
When I ng build/serve I got the following warning =
(node:3926) [DEP_WEBPACK_DEPRECATION_ARRAY_TO_SET_INDEXER] DeprecationWarning: chunk.files was changed from Array to Set (indexing Array is deprecated)
(Use `node --trace-deprecation ...` to show where the warning was created)
Any idea of what should I do? replace all Array by Set? and where can I put this node --trace-deprecation in my app in order to know what file cause this problem?
Thank you.
UPDATE
I added --trace-deprecation during build and got the following logs :
(node:12987) [DEP_WEBPACK_DEPRECATION_ARRAY_TO_SET_INDEXER] DeprecationWarning: chunk.files was changed from Array to Set (indexing Array is deprecated)
at Set.fn (/Users/xxxxx/node_modules/webpack/lib/util/deprecation.js:128:4)
at xxx/node_modules/#angular-devkit/build-angular/src/webpack/plugins/analytics.js:173:57
at Array.forEach (<anonymous>)
at NgBuildAnalyticsPlugin._collectBundleStats (/xxxx/node_modules/#angular-devkit/build-angular/src/webpack/plugins/analytics.js:172:14)
at NgBuildAnalyticsPlugin._done (/xxx/node_modules/#angular-devkit/build-angular/src/webpack/plugins/analytics.js:242:14)
at Hook.eval [as callAsync] (eval at create (/xxx/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:14:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/xxx/node_modules/tapable/lib/Hook.js:18:14)
at /xxx/node_modules/webpack/lib/Compiler.js:468:23
at Compiler.emitRecords (/xxx/node_modules/webpack/lib/Compiler.js:846:39)
at /xxx/node_modules/webpack/lib/Compiler.js:460:11
Currently, Angular 11 with Webpack 5 is still experimental and work with Yarn only as mentioned here. So you may see some warning and errors here and there. I believe it is better to avoid production builds with it for now.
Most probably that it will be offically supported by Angular 12. You can see here that #angular-devkit/build-optimizer library will be supporting Webpack 5 in version 12.
What is meant by this?
(node:52213) Warning: Accessing non-existent property 'MongoError' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:52213) DeprecationWarning: Listening to events on the Db class has been deprecated and will be removed in the next major version.
You can just ignore this warning for now,
look at this answer by Lauren_Schaefer which is a MongoDB Employee.
Link for the answer from the mongoDB developers community is here:
https://developer.mongodb.com/community/forums/t/warning-accessing-non-existent-property-mongoerror-of-module-exports-inside-circular-dependency/15411/6
My code is running fine in localhost with no warnings but when I'm changing my connection string to the string provided by mongodb atlas, following errors are showing which you can see in the below pic and my browser keeps circulating plz guide me what I'm doing wrong
(node:13700) DeprecationWarning: 'open()' is deprecated in mongoose >=
4.11.0,
use 'openUri() instead, or set the 'useMongoClient' option if using 'connect()' or 'createConnection()'. See
http://mongoosejs.com/docs/4.x/docs/connections.html#use-mongo-client
(Use 'node --trace-deprecation... to show where the warning was
created)
Server started on port 3000
Error [MongoError]: failed to connect to server [undefined:27017] on first connect [Error: getaddrinfo ENOTFOUND undefined
at GetAddrInfoReqwrap.onlookup [as oncomplete] (dns.js:67:26) {}] name: 'MongoError'
at Pool. (C:\Users\Umer\Desktop\node\Alhamdulillah, complete webapp\All Validations Completed\node_modules\mongodb-core\lib\topologies\server.js: 336:35)
at Pool.emit (events.js:315 :20) at Connection.
(C:\Users\Umer\Desktop\node\Alhamdulillah, complet e webapp\A11
Validations Completed\node_modules\mongodb-core\lib\connection\poo1
Lis:280:12)
screenshot
According to the problem that you're facing, it is because you're coding the deprecated method of connecting to the MongoDB.
Your database.js file seems okay but I would suggest that you use dotenv and not a separate file for your secrets
But in your app.js file, kindly completely change the way you're connecting to MongoDB.
const config = require('./config/database')
const options = {useUnifiedTopology: true, useNewUrlParser: true}
mongoose.connect(config.mongoURI, options).then(
()=> console.log('connected to mongodb'),
(reason)=> console.error(`Error: ${reason}`)
)
// All of your other code ahead.
Happy Coding!