I have an app that has node js in the backend. in the dev side it is working fine. but in the prod with the built/compiled code, I got this error ReferenceError: regeneratorRuntime is not defined
I have tried this solution but it is not working for me
babel.config.json
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
],
"plugins": ["@babel/plugin-proposal-object-rest-spread", "@babel/plugin-transform-runtime"]
}
the entry file server.js that calls the db connection file
import "core-js/stable"
import "regenerator-runtime/runtime"
require("dotenv").config()
import db from "./db"
const init = async () => {
try {
await db()
} catch (err) {
throw new Error(err)
}
const opts = {
port: process.env.PORT || 4000,
cors: {
origin: process.env.FRONTENDURL,
credentials: true
}
}
const server = require("./graphql/index")
server.start(opts, t => {
console.log(`server is up ${opts.port}`)
})
}
init()
the db file where the error is originated
const mongodb = require("mongodb")
export default () => {
return new Promise((resolve, reject) => {
mongodb.connect(process.env.CONNECTIONSTRING, { useNewUrlParser: true, useUnifiedTopology: true }, function (err, client) {
if (err) {
return reject(err)
}
module.exports = client
return resolve()
})
})
}
also the build script in packagejson
"scripts": {
"build": "babel src --out-dir dist --copy-files",
},