Ask coding questions

← Back to all posts
NodeJS Database Error [CLOSED]
lightningrock (151)

When I try to use's database in NodeJS, which I import on lines 8 and 9, it says the @replit/database modules wasn't found.

Error: Cannot find module '@replit/database'
Require stack:
- /home/runner/lightningrock/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js

uh, everything seems to be working.

lightningrock (151)

I've commented it out, because otherwise it won't run. @RYANTADIPARTHI


@lightningrock well, one problem is the import.import repl db like this.

from replit import db

not exactly like that, but in node js, import it properly. Not /

lightningrock (151)

But replit says to import it like this:

Anyways how do I do it without the /?


Pankak (48)

@RYANTADIPARTHI thats python, he's using nodes


@lightningrock maybe this.

import db from replit
Pankak (48)

@lightningrock I am fairly certain this is a bug unless you did something super wacky to mess up the file structures

lightningrock (151)

@Pankak @RYANTADIPARTHI It's working now. For some reason when I did require("@replit/database"), it didn't automatically install the package. I've installed it manually and it works now.

Pankak (48)

@lightningrock alright, yeah you want to learn to manually install, repl is whacky sometimes

Coder100 (18187)

you don't install packages?

and then
npm i @replit/database

their upm rarely detects packages correctly.