{"id":697,"hash":"f6f5c0616e0bf50b173130a7628887c2a18ec00115351688649536b7d000e8df","pattern":"(node:63208) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead","full_message":"Where is this error coming from? I am not using ensureIndex or createIndex in my Nodejs application anywhere. I am using yarn package manager.\n\nHere is my code in index.js\n\nimport express from 'express';\nimport path from 'path';\nimport bodyParser from 'body-parser';\nimport mongoose from 'mongoose';\nimport Promise from 'bluebird';\n\ndotenv.config();\nmongoose.Promise = Promise;\nmongoose.connect('mongodb://localhost:27017/bookworm', { useNewUrlParser: true });\n\nconst app = express();","ecosystem":"npm","package_name":"node.js","package_version":null,"solution":"The issue is that mongoose still uses collection.ensureIndex and should be updated by them in the near future. To get rid of the message you can downgrade by using version 5.2.8 in your package.json (and delete any caches, last resort is to uninstall it the install it with npm install mongoose@5.2.8):  \n\n  \"mongoose\": \"^5.2.8\"\n\nEDIT:\nAs of this edit, Mongoose is now at v5.4.13. Per their docs, these are the fixes for the deprecation warnings...\n\nmongoose.set('useNewUrlParser', true);\nmongoose.set('useFindAndModify', false);\nmongoose.set('useCreateIndex', true);\n\n  Replace update() with updateOne(), updateMany(), or replaceOne()\n\n  \n  Replace remove() with deleteOne() or deleteMany().\n\n  \n  Replace count() with countDocuments(), unless you want to count how many documents are in the whole collection (no filter). In the latter case, use estimatedDocumentCount().","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/51960171/node63208-deprecationwarning-collection-ensureindex-is-deprecated-use-creat","votes":116,"created_at":"2026-04-19T04:51:30.405880+00:00","updated_at":"2026-04-19T04:51:30.405880+00:00"}