节点Sequelize Heroku部署错误代码= H10 desc =“应用程序崩溃”方法= GET路径=“ /”

时间:2018-12-09 06:59:15

标签: node.js express heroku mysql-workbench sequelize-cli

我尝试了在这里找到的所有解决方案,但仍然无法在Heroku上部署该应用程序 我找到并尝试过的方法:

     - updated all packages,
     - heroku restart
     - checked on start server.js 

("scripts": {
        "start": "node server.js"
      }

,          -用||指定的PORT          -添加引擎npm和节点:

"engines": {
        "node": "v10.4.0",
        "npm": "6.4.1"
      }
     - added a sequelizerc:

var path = require ('path');
    module.exports = {
        'config': path.resolve('config', 'config.js')
    }

仍然得到错误代码= H10 desc =“应用程序崩溃”方法= GET路径=“ /”

   Here is my **package.json**



    {
          "name": "sample",
          "version": "1.0.0",
          "description": "sample description",
          "main": "server.js",
          "scripts": {
            "start": "node server.js"
          },
          "license": "ISC",
          "dependencies": {
            "bcrypt-nodejs": "0.0.3",
            "body-parser": "^1.18.3",
            "dotenv": "^6.2.0",
            "express": "^4.16.4",
            "express-handlebars": "^3.0.0",
            "express-session": "^1.15.6",
            "http": "0.0.0",
            "install": "^0.12.2",
            "materialize-css": "^1.0.0",
            "mysql": "^2.16.0",
            "mysql2": "^1.6.4",
            "ngrok": "^3.1.0",
            "node-fetch": "^2.3.0",
            "nodemon": "^1.18.7",
            "passport": "^0.4.0",
            "passport-local": "^1.0.0",
            "path": "^0.12.7",
            "sequelize": "^4.41.2"
          },
          "devDependencies": {
            "chai": "^4.1.2",
            "chai-http": "^4.0.0",
            "eslint-config-prettier": "^2.9.0",
            "eslint-plugin-prettier": "^2.6.2",
            "mocha": "^5.2.0",
            "prettier": "^1.13.7"
          },
          "engines": {
            "node": "v10.4.0",
            "npm": "6.4.1"
          }
        }


        ----------

        **server.js** 

        require("dotenv").config();
        var express = require("express");
        var passport   = require('passport')
        var session    = require('express-session')
        var bodyParser = require('body-parser')
        var env = require('dotenv').load()
        var exphbs = require("express-handlebars");


        var app = express();
        var PORT = process.env.PORT || 3000;

        // Middleware
        app.use(express.urlencoded({ extended: false }));
        app.use(express.json());
        app.use(express.static("public"));


        //For BodyParser
        app.use(bodyParser.urlencoded({ extended: true }));
        app.use(bodyParser.json());

        // For Passport 
        app.use(session({ secret: 'keyboard cat',resave: true, saveUninitialized:true})); // session secret
        app.use(passport.initialize());
        app.use(passport.session()); // persistent login sessions



        // Handlebars
        app.engine(
          "handlebars",
          exphbs({
            defaultLayout: "main"
          })
        );
        app.set("view engine", "handlebars");


        //Homepage
        app.get("/", function (req, res) {
          res.render("homepage");
        });


        //Models
        var models = require("./models");


        //Routes
        var authRoute = require('./routes/auth.js')(app,passport);

        require("./routes/html-routes")(app);
        require("./routes/trip-api-routes")(app);
        require("./routes/user-api-routes")(app);



        //load passport strategies
        require('./config/passport/passport.js')(passport, models.User);


        //Sync Database

        // If running a test, set syncOptions.force to true
        var syncOptions = { force: false };


        if (process.env.NODE_ENV === "test") {
          syncOptions.force = true;
        }


        models.sequelize.sync(syncOptions).then(function() {
          app.listen(PORT, function() {
            console.log(
              "==>   Listening on port %s. Visit http://localhost:%s/ in your browser.",
              PORT,
              PORT
            );
          });
        })

        module.exports = app;


Here is the heroku logs
2018-12-09T06:27:54.869376+00:00 heroku[web.1]: Starting process with command `npm start`
2018-12-09T06:27:56.809084+00:00 app[web.1]:
2018-12-09T06:27:56.809113+00:00 app[web.1]: > localize1@1.0.0 start /app
2018-12-09T06:27:56.809115+00:00 app[web.1]: > node server.js
2018-12-09T06:27:56.809117+00:00 app[web.1]:
2018-12-09T06:27:57.116326+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2018-12-09T06:27:57.116366+00:00 app[web.1]: designed for a production environment, as it will leak
2018-12-09T06:27:57.116368+00:00 app[web.1]: memory, and will not scale past a single process.
2018-12-09T06:27:57.495001+00:00 app[web.1]: Sun, 09 Dec 2018 06:27:57 GMT sequelize deprecated String based operators are now deprecated. Please use Symbol based operators for better security, read more at http://docs.sequelizejs.com/manual/tutorial/querying.html#operators at node_modules/sequelize/lib/sequelize.js:242:13
2018-12-09T06:27:57.527335+00:00 app[web.1]: internal/modules/cjs/loader.js:596
2018-12-09T06:27:57.527355+00:00 app[web.1]: throw err;
2018-12-09T06:27:57.527357+00:00 app[web.1]: ^
2018-12-09T06:27:57.527358+00:00 app[web.1]:
2018-12-09T06:27:57.527361+00:00 app[web.1]: Error: Cannot find module '../controllers/authcontroller.js'
2018-12-09T06:27:57.527363+00:00 app[web.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
2018-12-09T06:27:57.527365+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:520:25)
2018-12-09T06:27:57.527367+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:650:17)
2018-12-09T06:27:57.527368+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:20:18)
2018-12-09T06:27:57.527370+00:00 app[web.1]: at Object.<anonymous> (/app/routes/auth.js:1:84)
2018-12-09T06:27:57.527372+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:702:30)
2018-12-09T06:27:57.527374+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
2018-12-09T06:27:57.527376+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:612:32)
2018-12-09T06:27:57.527377+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
2018-12-09T06:27:57.527379+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:543:3)
2018-12-09T06:27:57.527381+00:00 app[web.1]: at Module.require (internal/modules/cjs/loader.js:650:17)
2018-12-09T06:27:57.527382+00:00 app[web.1]: at require (internal/modules/cjs/helpers.js:20:18)
2018-12-09T06:27:57.527384+00:00 app[web.1]: at Object.<anonymous> (/app/server.js:60:17)
2018-12-09T06:27:57.527386+00:00 app[web.1]: at Module._compile (internal/modules/cjs/loader.js:702:30)
2018-12-09T06:27:57.527387+00:00 app[web.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
2018-12-09T06:27:57.527388+00:00 app[web.1]: at Module.load (internal/modules/cjs/loader.js:612:32)
2018-12-09T06:27:57.527390+00:00 app[web.1]: at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
2018-12-09T06:27:57.527391+00:00 app[web.1]: at Function.Module._load (internal/modules/cjs/loader.js:543:3)
2018-12-09T06:27:57.527392+00:00 app[web.1]: at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
2018-12-09T06:27:57.527394+00:00 app[web.1]: at startup (internal/bootstrap/node.js:238:19)
2018-12-09T06:27:57.527395+00:00 app[web.1]: at bootstrapNodeJSCore (internal/bootstrap/node.js:572:3)
2018-12-09T06:27:57.535362+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2018-12-09T06:27:57.535781+00:00 app[web.1]: npm ERR! errno 1
2018-12-09T06:27:57.536921+00:00 app[web.1]: npm ERR! localize1@1.0.0 start: `node server.js`
2018-12-09T06:27:57.537025+00:00 app[web.1]: npm ERR! Exit status 1
2018-12-09T06:27:57.538934+00:00 app[web.1]: npm ERR!
2018-12-09T06:27:57.539220+00:00 app[web.1]: npm ERR! Failed at the localize1@1.0.0 start script.
2018-12-09T06:27:57.539354+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-12-09T06:27:57.546712+00:00 app[web.1]:
2018-12-09T06:27:57.546879+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-12-09T06:27:57.546952+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2018-12-09T06_27_57_540Z-debug.log
2018-12-09T06:27:57.608612+00:00 heroku[web.1]: Process exited with status 1
2018-12-09T06:31:17.996340+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=e-localize.herokuapp.com request_id=61ec32d5-0129-44fb-9c1e-980c46594b0f fwd="73.35.190.34" dyno= connect= service= status=503 bytes= protocol=https
2018-12-09T06:31:18.422313+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=e-localize.herokuapp.com request_id=43cd2930-4555-4047-b437-48d9a0b7e6f6 fwd="73.35.190.34" dyno= connect= service= status=503 bytes= protocol=https
2018-12-09T06:32:18.757301+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=e-localize.herokuapp.com request_id=529ab53d-04d5-47e5-a457-fd7bf3996dbf fwd="73.35.190.34" dyno= connect= service= status=503 bytes= protocol=https
2018-12-09T06:32:19.120225+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=e-localize.herokuapp.com request_id=a8d9f677-2a65-4aa9-96c9-c74573bbbeda fwd="73.35.190.34" dyno= connect= service= status=503 bytes= protocol=https
2018-12-09T06:32:20.744745+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=e-localize.herokuapp.com request_id=61981588-2cb2-4973-8cbf-98399334b294 fwd="73.35.190.34" dyno= connect= service= status=503 bytes= protocol=https
2018-12-09T06:32:21.104250+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=e-localize.herokuapp.com request_id=0ac8e0f0-f078-4efb-899f-a4738458be89 fwd="73.35.190.34" dyno= connect= service= status=503 bytes= protocol=https

该应用程序在ngrok和localhost上运行良好,并且数据库已通过JAWSDB连接到Heroku,但与它的heroku链接仍未打开,并且我的sql工作台中的表为空。

0 个答案:

没有答案