javascriptnext.jstypeorm

Typeorm throws a bson error in next.js app


I am working on adding typeorm into my Next.js app. however even though i am using the mysql2 driver and 5 data sources I can't seem to get rid of the bson error of:

./node_modules/typeorm/browser/driver/mongodb/bson.typings.js
Module parse failed: Export 'BSON' is not defined (1:9)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> export { BSON };
| 
| //# sourceMappingURL=bson.typings.js.map

Here is the main data source I am trying to use:

export const MI_Website = new DataSource({
    type: "mysql",
    host: process.env.BD_HOST as string,
    // port: process.env.DB_PORT || 3306,
    port: parseInt(process.env.DB_PORT as string) || 3306,
    username: process.env.DB_USERNAME as string,
    password: process.env.DB_PASSWORD as string,
    database: process.env.DB_DATABASE1 as string,
    entities: [__dirname + "/entity/website/*{.jsx,.tsx,.js,.ts}"],
    synchronize: true,
})

Help would be greatly appreciated. Despite searching I have not found any fixes for this problem just yet.


Solution

  • That's a bug. Right now it is work in progress. ISSUE