I am trying to use the replit database in my nodeJS project. I am using ES6 and when I try to import the replit DB I get the errors below
const db = require("@replit/database");
const db = require("@replit/database"); ^ ReferenceError: require is not defined in ES module scope, you can use import instead This file is being treated as an ES module because it has a '.js' file extension and '/home/runner/jsbookie-backend/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension. at file:///home/runner/jsbookie-backend/index.js:4:12 at ModuleJob.run (node:internal/modules/esm/module_job:193:25) at async Promise.all (index 0) at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
And I tried using the info to import the database in a way that would work with ES 6 – but I believe the example given is for Python, not js.
// Import the Replit database import db from replit/database;
file:///home/runner/jsbookie-backend/index.js:3 import db from replit/database; ^^^^^^ SyntaxError: Unexpected identifier at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:119:18) at ESMLoader.moduleProvider (node:internal/modules/esm/loader:468:14)