[Mongoose] (node:42286) 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. の解決方法
Express (Node.js) + Mongoose (MongoDB) という構成の Web アプリケーションで、 (node:42286) 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:42286) 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.
const mongoose = require('mongoose');
mongoose.connect(process.env.MONGODB_URL);
const mongoose = require('mongoose');
mongoose.connect(process.env.MONGODB_URL, { useNewUrlParser: true });
以上、Express + Mongoose で DeprecationWarning 無く開発していきたい、現場からお送りしました。