我有这个错误:
`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'}`
这就是我想做的:
但是我在尝试 1/(第一步)时遇到了问题。上面给出的问题
node_modules
包并重新安装所有依赖项dist
文件夹并使用 package.json脚本中的
npm run build
但似乎没有什么能解决问题
我不知道我做错了什么。这是我的:
`{
"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
请任何帮助如何解决这个问题将帮助我最终部署应用程序。 谢谢您的宝贵时间。
在github中,我不小心推送了node_modules文件夹。我遇到了同样的问题。一旦我删除了node_modules文件夹,那么部署就成功了。