I can not connect mongoDB or Mongoose with Glitch,
when I am doing this,
import cors from "cors";
import cron from "node-cron";
import "dotenv/config";
import express from "express";
import mongoose from "mongoose";
It’s giving Error,
but if I comment the importation of mongoose,
import cors from "cors";
import cron from "node-cron";
import "dotenv/config";
import express from "express";
// import mongoose from "mongoose";
then everything is ok, but without mongoose I can do nothing.
This is just an example :
import cors from "cors";
import cron from "node-cron";
import "dotenv/config";
import express from "express";
import mongoose from "mongoose";
const app = express();
const port = process.env.PORT || 8000;
mongoose.connect(
`${process.env.DB_URI}`,
{ dbName: 'StayVistaDB'}
);
app.get("/", (req, res) => {
res.send("Hello from Hotelo Server..");
});
app.listen(port, () => {
console.log(`Hotelo is running on port ${port}`);
});
And the error is:
/rbd/pnpm-volume/c8b04a75-ce63-413d-abbd-f6ec73160356/node_modules/mongoose/node_modules/bson/lib/bson.cjs:479
11:09 AM
inspect ??= defaultInspect;
11:09 AM
^^^
11:09 AM
11:09 AM
SyntaxError: Unexpected token ‘??=’
Same Error for MongoDB too.
package.json:
{
"name": "glitch-hello-node",
"version": "0.1.0",
"description": "A simple Node app built on fastify, instantly up and running. Built to be remixed on Glitch.com.",
"type": "module",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"fastify": "^4.21.0",
"handlebars": "^4.7.8",
"@fastify/formbody": "^7.4.0",
"@fastify/static": "^6.10.2",
"@fastify/view": "^8.0.0",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"express": "^4.18.2",
"jsonwebtoken": "^9.0.2",
"morgan": "^1.10.0",
"node-cron": "^3.0.3",
"sslcommerz-lts": "^1.1.0",
"mongoose": "^8.0.3"
},
"engines": {
"node": "14.x"
},
"repository": {
"url": "https://glitch.com/edit/#!/glitch-hello-node"
},
"license": "ISC",
"keywords": [
"node",
"glitch"
]
}
Please Help me