How to resolve "mpromise (mongoose's default promise library) is deprecated" from a Typescript Application.
I'm getting the following error:
Left-hand side of assignment expression cannot be a constant or a read-only property.
I am using a MEAN stack with Angular 2 and would like to have mongoose use the bluebird promises library.
I am getting an error when I attempt to follow these instructions on Stack Overflow and Mongo
To be honest, I'm unsure if my issue is just lack of knowledge of Typescript or if I am doing something else wrong.
"use strict";
import * as mongoose from 'mongoose';
var dbConst = require('../constants/db.json');
var bluebird = require("bluebird");
export class DBConfig {
static init():void {
const URL = (process.env.NODE_ENV === 'production') ? process.env.MONGOHQ_URL
: dbConst.localhost;
mongoose.Promise = bluebird; // <-- THIS IS WHERE ERROR OCCURS
mongoose.connect(URL);
mongoose.connection.on('error', console.error.bind(console, 'An error ocurred with the DB connection: '));
}
};