【发布时间】:2021-02-15 10:18:29
【问题描述】:
正如标题所说,在我在那里部署我的系统之后,我不断收到无法获取 / ,所以当我输入 heroku 日志时,我得到了以下 2 个错误: 首先
(node:23) UnhandledPromiseRejectionWarning: MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
即使我为开发和生产服务器修复了我的参数变量,使用猫鼬连接我在代码中有 process.env.MONGODB 并且它在开发服务器上正常工作。
第二个错误是
(node:23) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
并且它没有对特定代码或行或文件的引用来知道错误的确切位置
这些是我对系统的依赖项
{
"name": "task-manager",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node src/app.js",
"dev": "env-cmd -f ./config/dev.env nodemon src/app.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@sendgrid/mail": "^7.3.0",
"bcryptjs": "^2.4.3",
"express": "^4.17.1",
"jsonwebtoken": "^8.5.1",
"mongodb": "^3.6.2",
"mongoose": "^5.10.9",
"multer": "^1.4.2",
"sharp": "^0.26.2",
"validator": "^13.1.17"
},
"devDependencies": {
"env-cmd": "^10.1.0",
"nodemon": "^2.0.5"
}
}
【问题讨论】:
标签: node.js heroku npm deployment