Express Server cannot create MongoClient "Cannot convert undefined or null to object"

I am trying to connect an express server to my mongo db, but consistently get the above error. The express server is the Angular (v17) SSR server that I just want to make a simple backend call to. I can build the application using ng build, but when served using npm run serve:ssr:project-name it quickly gives this output:

TypeError: Cannot convert undefined or null to object
    at Function.getPrototypeOf (<anonymous>)
    at file:///{{path}}/dist/server/server.mjs:106:285537
    at file:///{{path}}/dist/server/chunk-SRT5RB5B.mjs:2:1056
    at file:///{{path}}/lhotse/dist/server/server.mjs:106:554035
    at file:///{{path}}/lhotse/dist/server/chunk-SRT5RB5B.mjs:2:1056

My code:

import { MongoClient } from 'mongodb';
const pwd = process.env['MONGODB_PASSWORD'];
const db = process.env['MONGODB_DBNAME'];
const cs = `mongodb+srv://root:${pwd}${db}?retryWrites=true&w=majority`;
const client = new MongoClient(cs);


  "dependencies": {
    "@angular/animations": "^17.2.0",
    "@angular/cdk": "^17.2.1",
    "@angular/common": "^17.2.0",
    "@angular/compiler": "^17.2.0",
    "@angular/core": "^17.2.0",
    "@angular/elements": "^17.2.3",
    "@angular/forms": "^17.2.0",
    "@angular/platform-browser": "^17.2.0",
    "@angular/platform-browser-dynamic": "^17.2.0",
    "@angular/platform-server": "^17.2.0",
    "@angular/router": "^17.2.0",
    "@angular/ssr": "^17.2.0",
    "dotenv": "^16.4.1",
    "express": "^4.18.2",
    "mongodb": "^6.4.0",
    "rxjs": "~7.8.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.14.3"

Grateful for any thoughts or directions…
PS Also tried with mongoose, same error

I am having the exact same issue.
Have you figured out a solution, yet?