tegaki
tegaki
DDeno
Created by tegaki on 2/18/2024 in #help
unable to connect to mongodb using deno inside container
First of all, I want to mention that when I run deno task preview on my local machine / laptop, it works 🎉 . No issues there. But I need to run my deno program inside a container for depolyment reasons (currently using fly.io) it fails. I'm using the official mongodb npm client. I use it via an import map (maybe that matters?), deno.json:
{
"imports": {
"db": "npm:mongodb@6.3.0",
}
}
{
"imports": {
"db": "npm:mongodb@6.3.0",
}
}
import { MongoClient } from "db";
// ...
const mongoClient = new MongoClient(url);
await mongoClient.connect();
// ...
import { MongoClient } from "db";
// ...
const mongoClient = new MongoClient(url);
await mongoClient.connect();
// ...
And when I try to run the code in a container I get the following error:
Task preview deno run -A main.ts
error: Uncaught (in promise) Error: Cannot find module 'bson'
Require stack:
- /app/node_modules/.deno/mongodb@6.3.0/node_modules/mongodb/lib/bson.js
- /app/node_modules/.deno/mongodb@6.3.0/node_modules/mongodb/lib/admin.js
- /app/node_modules/.deno/mongodb@6.3.0/node_modules/mongodb/lib/index.js
- /app/node_modules/.deno/mongodb@6.3.0/node_modules/mongodb/lib/index.js
at Function.Module._resolveFilename (node:module:622:15)
at Function.Module._load (node:module:500:27)
at Module.require (node:module:675:19)
at require (node:module:789:16)
at Object.<anonymous> (file:///app/node_modules/.deno/mongodb@6.3.0/node_modules/mongodb/lib/bson.js:4:14)
at Object.<anonymous> (file:///app/node_modules/.deno/mongodb@6.3.0/node_modules/mongodb/lib/bson.js:63:4)
at Module._compile (node:module:731:34)
at Object.Module._extensions..js (node:module:745:10)
at Module.load (node:module:656:32)
at Function.Module._load (node:module:537:12)
Task preview deno run -A main.ts
error: Uncaught (in promise) Error: Cannot find module 'bson'
Require stack:
- /app/node_modules/.deno/mongodb@6.3.0/node_modules/mongodb/lib/bson.js
- /app/node_modules/.deno/mongodb@6.3.0/node_modules/mongodb/lib/admin.js
- /app/node_modules/.deno/mongodb@6.3.0/node_modules/mongodb/lib/index.js
- /app/node_modules/.deno/mongodb@6.3.0/node_modules/mongodb/lib/index.js
at Function.Module._resolveFilename (node:module:622:15)
at Function.Module._load (node:module:500:27)
at Module.require (node:module:675:19)
at require (node:module:789:16)
at Object.<anonymous> (file:///app/node_modules/.deno/mongodb@6.3.0/node_modules/mongodb/lib/bson.js:4:14)
at Object.<anonymous> (file:///app/node_modules/.deno/mongodb@6.3.0/node_modules/mongodb/lib/bson.js:63:4)
at Module._compile (node:module:731:34)
at Object.Module._extensions..js (node:module:745:10)
at Module.load (node:module:656:32)
at Function.Module._load (node:module:537:12)
checklist: - same version of deno both places - I've tried connecting to mongodb with the deno package mongo but I get another error about the driver not supporting load balancing... so I guess it's just out of date? (6 months since last release) - I've tried to base my image on ubuntu:latest (install deno + run) same issue 🤔
7 replies