npmnode.js95% confidence\u2191 116

(node:63208) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead

Full error 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.

Here is my code in index.js

import express from 'express';
import path from 'path';
import bodyParser from 'body-parser';
import mongoose from 'mongoose';
import Promise from 'bluebird';

dotenv.config();
mongoose.Promise = Promise;
mongoose.connect('mongodb://localhost:27017/bookworm', { useNewUrlParser: true });

const app = express();

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 [email protected]): "mongoose": "^5.2.8" EDIT: As of this edit, Mongoose is now at v5.4.13. Per their docs, these are the fixes for the deprecation warnings... mongoose.set('useNewUrlParser', true); mongoose.set('useFindAndModify', false); mongoose.set('useCreateIndex', true); Replace update() with updateOne(), updateMany(), or replaceOne() Replace remove() with deleteOne() or deleteMany(). 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().

API access

Get this solution programmatically \u2014 free, no authentication.

curl https://depscope.dev/api/error/f6f5c0616e0bf50b173130a7628887c2a18ec00115351688649536b7d000e8df
hash \u00b7 f6f5c0616e0bf50b173130a7628887c2a18ec00115351688649536b7d000e8df
(node:63208) DeprecationWarning: collection.ensureIndex is d… — DepScope fix | DepScope