Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 尝试在Heroku上运行节点应用程序时出错_Node.js_Heroku - Fatal编程技术网

Node.js 尝试在Heroku上运行节点应用程序时出错

Node.js 尝试在Heroku上运行节点应用程序时出错,node.js,heroku,Node.js,Heroku,这就是我得到的错误。论美术作品的发展。我确实设置了环境变量。它似乎无法提供应用程序文件,但我不知道为什么。如果有人知道该做什么,我会非常感谢他 我需要写更多的信来邮寄,所以我在写 2021-05-17T20:28:11.107507+00:00 app[web.1]: at node:internal/main/run_main_module:17:47 { 2021-05-17T20:28:11.107508+00:00 app[web.1]: code: 'MODULE_NOT_

这就是我得到的错误。论美术作品的发展。我确实设置了环境变量。它似乎无法提供应用程序文件,但我不知道为什么。如果有人知道该做什么,我会非常感谢他 我需要写更多的信来邮寄,所以我在写

2021-05-17T20:28:11.107507+00:00 app[web.1]:     at node:internal/main/run_main_module:17:47 {
2021-05-17T20:28:11.107508+00:00 app[web.1]:   code: 'MODULE_NOT_FOUND',
2021-05-17T20:28:11.107508+00:00 app[web.1]:   requireStack: [ '/app/app.js' ]
2021-05-17T20:28:11.107508+00:00 app[web.1]: }
2021-05-17T20:28:11.189001+00:00 heroku[web.1]: Process exited with status 1
2021-05-17T20:28:11.410642+00:00 heroku[web.1]: State changed from starting to crashed
2021-05-17T20:28:21.518307+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=calm-mountain-35340.herokuapp.com request_id=7723a506-9be4-4a70-b196-fbbd09d32a41 fwd="213.151.62.36" dyno= connect= service= status=503 bytes= protocol=https
2021-05-17T20:28:21.766598+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=calm-mountain-35340.herokuapp.com request_id=8f45c788-fb29-42df-bb69-fa0217fae19f fwd="213.151.62.36" dyno= connect= service= status=503 bytes= protocol=https
2021-05-17T20:34:13.296507+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=calm-mountain-35340.herokuapp.com request_id=aa2f7bfb-ebd6-4d50-9cd0-bfa4e28d0fd3 fwd="213.151.62.36" dyno= connect= service= status=503 bytes= protocol=https
2021-05-17T20:34:13.712421+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=calm-mountain-35340.herokuapp.com request_id=28b98179-cb1e-4047-b8b2-5edaaf2e36a0 fwd="213.151.62.36" dyno= connect= service= status=503 bytes= protocol=https

Source code of app file

const path = require('path');
const express = require('express');
const bodyParser = require('body-parser');
// const errorController = require('./controllers/error');
const session = require('express-session');
const MongoDBStore = require('connect-mongodb-session')(session);
const fs = require('fs');
const ca = [fs.readFileSync(__dirname + '/cert.pem')];
const User = require('./models/user');
const mongoose = require('mongoose');
const csrf = require('csurf');
const cors = require('cors');
const dotenv = require('dotenv');
const checkDevelopment = process.env.NODE_ENV === 'development';
console.log(checkDevelopment);
dotenv.config();
const uri = process.env.MONGO_CONNECT;
console.log(process.env.MONGO_USER);
const mongodbURL = uri;
const app = express();

app.use(bodyParser.json());
const corsOptions = {
  origin: '*',
  optionsSuccessStatus: 200,
};
app.use(cors(corsOptions));
const userRoutes = require('./routes/user');

const authRoutes = require('./routes/auth');

app.use(userRoutes);
app.use(authRoutes);

mongoose
  .connect(mongodbURL, {
    useNewUrlParser: true,
    useUnifiedTopology: true,

    sslCA: ca,
  })
  .then(result => app.listen(process.env.PORT || 3003));```

确保您已经安装了软件包


>npm安装

如果您显示源代码,将非常有用。