Improviser 14
Improviser 14

Reputation: 35

new heroku[router]: at=error code=H10 desc="App crashed"

I'm getting the above error from 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. 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? 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:

    {
    "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. Thanks in advance for the help.

Upvotes: 0

Views: 198

Answers (1)

Alex Naish
Alex Naish

Reputation: 120

The stacktrace is telling you what is going wrong, most importantly:

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. It's not complaining about not being able to find your .env file, its complaining that it can't resolve the dotenv module.

Considering what dotenv does, it should be a production dependency and should be moved from devDependencies into dependencies.

Upvotes: 1

Related Questions