Node modules error

Hi, I’m currently having some problem deploying my mern stack project. It’s currently having some node modules problem. But when i run the app locally with npm run build and npm start, it is working fine.

link to project: GitHub - nhinewyenn/finance


==> Common ways to troubleshoot your deploy:
==> Using Node version 20.11.1 via environment variable NODE_VERSION
==> Docs on specifying a Node version:
==> Running 'cd backend && npm start'
> server@1.0.0 start
> node ./dist/api/index.js
      throw e;
Error: Cannot find module '/opt/render/project/src/backend/node_modules/@mongodb-js/saslprep/dist/node.js'
    at createEsmNotFoundErr (node:internal/modules/cjs/loader:1181:15)
    at finalizeEsmResolution (node:internal/modules/cjs/loader:1169:15)
    at resolveExports (node:internal/modules/cjs/loader:591:14)
    at Module._findPath (node:internal/modules/cjs/loader:668:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1130:27)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (/opt/render/project/src/backend/node_modules/mongodb/lib/cmap/auth/scram.js:4:20)
    at Module._compile (node:internal/modules/cjs/loader:1376:14) {
  path: '/opt/render/project/src/backend/node_modules/@mongodb-js/saslprep/package.json'
Node.js v20.11.1

Some steps that I’ve taken:

  • Deleted node modules and reinstall rm -rf node_modules && npm install .
  • Cache clean with npm cache clean
  • Run npm ls @mongodb-js/saslprep, output below:
server@1.0.0 /Users/nhinguyen/Downloads/coding-projects/finance/backend
├── @mongodb-js/saslprep@1.1.4
└─┬ mongodb@6.3.0
  └── @mongodb-js/saslprep@1.1.4 deduped

This is my package json file:

  "name": "server",
  "version": "1.0.0",
  "description": "",
  "main": "./index.js",
  "scripts": {
    "build": "npm install && npx tsc",
    "start": "node ./dist/api/index.js",
    "dev": "node --watch \"./**\" --ext \"ts,json\" --exec \"ts-node ./src/index.ts\"",
    "vercel-build": "echo hello"
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@mongodb-js/saslprep": "^1.1.4",
    "@types/basic-auth": "^1.1.7",
    "@types/body-parser": "^1.19.5",
    "@types/express-session": "^1.17.10",
    "@types/jsonwebtoken": "^9.0.5",
    "basic-auth": "^2.0.1",
    "bcrypt": "^5.1.1",
    "body-parser": "^1.20.2",
    "cookie-parser": "^1.4.6",
    "cors": "^2.8.5",
    "dotenv": "^16.3.1",
    "express": "^4.18.2",
    "express-session": "^1.17.3",
    "jsonwebtoken": "^9.0.2",
    "mongodb": "^6.2.0",
    "mongoose": "^8.0.3",
    "saslprep": "^1.0.3",
    "typescript": "^5.3.3"
  "devDependencies": {
    "@types/bcrypt": "^5.0.2",
    "@types/cookie-parser": "^1.4.6",
    "@types/cors": "^2.8.17",
    "@types/express": "^4.17.21",
    "@types/mongodb": "^4.0.7",
    "@types/mongoose": "^5.11.97",
    "@types/node": "^20.10.7",
    "ts-node": "^10.9.2"


I’ve replied to the ticket you also opened. Let’s keep the conversation in one place (on the ticket). Then you can update this post when we get to the solution.


1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.