[英]new heroku[router]: at=error code=H10 desc=“App crashed”
I'm getting the above error from heroku. 我从heroku收到上述错误。 I've tried several of the solutions including: updating the engine in package.json for both the node version and npm, as well as using the heroku restart command.
我尝试了几种解决方案,包括:在package.json中为节点版本和npm更新引擎,以及使用heroku restart命令。 I also made sure that the port on my DB config wasn't hard coded as some answers suggested.
我还确保我的数据库配置上的端口没有按照某些答案建议进行硬编码。 Here is my config:
这是我的配置:
var url = process.env.DATABASEURL || "mongodb://localhost/roam-
hub";
mongoose.connect(url);
The error also points to my dotenv file, which is connected and configured correctly I think? 错误也指向我的dotenv文件,我认为该文件已正确连接和配置? Everything works fine on my local environment.
在我的本地环境下,一切正常。 Does anyone have a new suggestion on how to troubleshoot this problem?
是否有人对如何解决此问题有新的建议?
throw err;
2018-09-12T12:22:20.970580+00:00 app[web.1]: ^
2018-09-12T12:22:20.970582+00:00 app[web.1]:
2018-09-12T12:22:20.970583+00:00 app[web.1]: Error: Cannot find
module 'dotenv'
2018-09-12T12:22:20.970585+00:00 app[web.1]: at
Function.Module._resolveFilename
(internal/modules/cjs/loader.js:594:15)
Here is my package.json file: 这是我的package.json文件:
{
"name": "roam-app",
"version": "1.0.0",
"engines": {
"node": "10.5.0",
"npm": "6.2.0"
},
"description": "central app for all things Roam",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js"
},
"author": "*",
"license": "ISC",
"dependencies": {
"body-parser": "^1.18.3",
"cloudinary": "^1.11.0",
"connect-flash": "^0.1.1",
"connect-timeout": "^1.9.0",
"cookie-parser": "^1.4.3",
"ejs": "^2.6.1",
"express": "^4.16.3",
"express-session": "^1.15.6",
"method-override": "^2.3.10",
"moment": "^2.22.2",
"mongoose": "^5.1.5",
"multer": "^1.3.1",
"nodemailer": "^4.6.7",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"passport-local-mongoose": "^5.0.0",
"request": "^2.87.0",
"session": "^0.1.0"
},
"devDependencies": {
"dotenv": "^6.0.0"
}
}
I started getting this error after I changed some basic HTML files and pushed to heroku. 在更改了一些基本的HTML文件并将其推送到heroku之后,我开始出现此错误。 Thanks in advance for the help.
先谢谢您的帮助。
The stacktrace is telling you what is going wrong, most importantly: stacktrace告诉您出了什么问题,最重要的是:
Error: Cannot find module 'dotenv'
I suspect that you're doing a npm install --production
and its installing only the dependencies listed under your dependencies
in your package.json whereas dotenv
is listed as a devDependency
and hence not being installed. 我怀疑您正在执行
npm install --production
及其仅安装在package.json中的依赖项下列出的dependencies
,而dotenv
被列为devDependency
,因此未安装。 It's not complaining about not being able to find your .env
file, its complaining that it can't resolve the dotenv
module. 它不是在抱怨找不到您的
.env
文件, .env
在抱怨它无法解析dotenv
模块。
Considering what dotenv
does, it should be a production dependency and should be moved from devDependencies
into dependencies
. 考虑到
dotenv
作用,它应该是生产依赖项,应该从devDependencies
移到dependencies
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.