# 错误:MongoDB 在 Render.com 网站部署应用程序

问题描述 投票:0回答:1

我有这个错误:

`Error: Cannot find module '/opt/render/project/src/server/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/server/node_modules/mongodb/lib/cmap/auth/scram.js:4:20)
at Module._compile (node:internal/modules/cjs/loader:1376:14) {code: 'MODULE_NOT_FOUND',path: '/opt/render/project/src/server/node_modules/@mongodb-js/saslprep/package.json'}`

进入render.com的实时看板报告

这就是我想做的:

  • 1/ 在 render.com 部署与在线餐厅相关的后端 Node 应用程序
  • 2/ 在 vercel 中部署我的反应应用程序

但是我在尝试 1/(第一步)时遇到了问题。上面给出的问题

我尝试过:

  • 删除
    node_modules
    包并重新安装所有依赖项
  • 删除
    dist
    文件夹并使用
    package.json
    脚本中的 npm run build
  • 命令集重建它
  • 根据这些更改
  • 更新github上的存储库

但似乎没有什么能解决问题

我不知道我做错了什么。这是我的:

package.json 文件

`{
    "name": "server",
    "version": "1.0.0",
    "description": "backend\\ bridge between mongoDb and client frontend app",
    "main": "server.js",
    "scripts": {
    "start": "node dist/server.js",
    "build": "babel src -d dist",
    "dev": "nodemon --exec babel-node src/server.js",
    "both-dev": " concurrently \"npm run dev\" \"npm --prefix ../client/ run dev\" "
    },
  "author": "Gerard",
  "license": "ISC",
  "dependencies": {
  "bcryptjs": "^2.4.3",
  "body-parser": "^1.20.2",
  "cookie-parser": "^1.4.6",
  "cors": "^2.8.5",
  "date-fns": "^3.0.6",
  "dotenv": "^16.4.5",
  "express": "^4.19.1",
  "express-jwt": "^8.4.1",
  "jsonwebtoken": "^9.0.2",
  "moment": "^2.30.1",
  "mongoose": "^8.2.3",
  "multer": "^1.4.5-lts.1",
  "qs": "^6.12.0",
  "validator": "^13.11.0"
  },
  "devDependencies": {
  "@babel/cli": "^7.24.1",
  "@babel/core": "^7.24.3",
  "@babel/node": "^7.23.9",
  "@babel/preset-env": "^7.24.3",
  "babel-plugin-module-resolver": "^5.0.0",
  "concurrently": "^8.2.2",
  "nodemon": "^3.1.0"
  }
}`

在我的应用程序的工作树下面:

`
tds-restaurant
   |
   |_ _ .github
   |
   |_ _ client ---
                 |
                 |_ _ node_modules
                 |
                 |_ _ src
                 |
                 |_ _ env.local
                 |
                 |_ _ eslintrc.js
                 |
                 |_ _ .gitignore
                 |
                 |_ _ index.html
                 |
                 |_ _ package-lock.json
                 |
                 |_ _ package.json
                 |
                 |_ _ README.md
   |             |
   |             |_ _ vite.config.js
   |
   |
   |_ _ server ---
                 |
                 | _ _dist
                 |
                 |_ _ node_modules
                 |
                 |_ _ src
                 |
                 |_ _ env
                 |
                 |_ _ .gitignore
                 |
                 |_ _ package-lock.json
                 |
                 |_ _ package.json

请任何帮助如何解决这个问题将帮助我最终部署应用程序。 谢谢您的宝贵时间。

node.js mongodb deployment backend render
1个回答
0
投票

在github中,我不小心推送了node_modules文件夹。我遇到了同样的问题。一旦我删除了node_modules文件夹,那么部署就成功了。

© www.soinside.com 2019 - 2024. All rights reserved.