首页 > 解决方案 > 将 vue 应用程序部署到 heroku

问题描述

我有一个 Vue 应用程序,我正在尝试使用“Heroku”在线部署,但出现应用程序错误,但是当我Heroku logs --tail在 cmd 中写入时,出现以下错误。这个问题中显示的代码是我如何为heroku进行生产。这是我的 git 存储库,我有应用程序的文件,没有 vue 的客户端文件夹https://github.com/isaacbajada1999/cw2

const path = require('path')

module.exports = {
    outputDir: path.resolve(__dirname, '../server/public'),
    devServer: {
        proxy: {
            '/api': {
                target: 'http://localhost:5000'
            }

        }
    }
};


// Handle production
if (process.env.NODE_ENV === 'production') {
    // Static folder
    app.use(express.static(__dirname + '/public/'));

    // Handle SPA
    app.get(/.*/, (req, res) => res.sendFile(__dirname + '/public/index.html'));
}
    C:\Users\isaac bajada\WebstormProjects\cw2\client>heroku logs --tail
2020-02-06T20:27:17.885755+00:00 app[api]: Initial release by user bajada1989@gmail.com
2020-02-06T20:27:17.885755+00:00 app[api]: Release v1 created by user bajada1989@gmail.com
2020-02-06T20:27:18.090853+00:00 app[api]: Enable Logplex by user bajada1989@gmail.com
2020-02-06T20:27:18.090853+00:00 app[api]: Release v2 created by user bajada1989@gmail.com
2020-02-06T20:28:33.000000+00:00 app[api]: Build started by user bajada1989@gmail.com
2020-02-06T20:28:51.584351+00:00 app[api]: Deploy 97c44d22 by user bajada1989@gmail.com
2020-02-06T20:28:51.584351+00:00 app[api]: Release v3 created by user bajada1989@gmail.com
2020-02-06T20:28:51.607979+00:00 app[api]: Scaled to web@1:Free by user bajada1989@gmail.com
2020-02-06T20:28:52.000000+00:00 app[api]: Build succeeded
2020-02-06T20:28:53.841932+00:00 heroku[web.1]: Starting process with command `npm start`
2020-02-06T20:28:56.319541+00:00 heroku[web.1]: State changed from starting to crashed
2020-02-06T20:28:56.323144+00:00 heroku[web.1]: State changed from crashed to starting
2020-02-06T20:28:56.298514+00:00 heroku[web.1]: Process exited with status 1
2020-02-06T20:28:56.202579+00:00 app[web.1]: npm ERR! missing script: start
2020-02-06T20:28:56.208582+00:00 app[web.1]:
2020-02-06T20:28:56.209047+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-02-06T20:28:56.209361+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-02-06T20_28_56_203Z-debug.log
2020-02-06T20:28:58.332047+00:00 heroku[web.1]: Starting process with command `npm start`
2020-02-06T20:29:00.244265+00:00 heroku[web.1]: State changed from starting to crashed
2020-02-06T20:29:00.224528+00:00 heroku[web.1]: Process exited with status 1
2020-02-06T20:29:00.145389+00:00 app[web.1]: npm ERR! missing script: start
2020-02-06T20:29:00.151218+00:00 app[web.1]:
2020-02-06T20:29:00.151697+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-02-06T20:29:00.151886+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-02-06T20_29_00_146Z-debug.log
2020-02-06T20:29:01.550754+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=morning-lowlands-63831.herokuapp.com request_id=6cfdf2a4-ad8a-4707-80b9-d4c920b27dd4 fwd=
"212.56.155.29" dyno= connect= service= status=503 bytes= protocol=https
2020-02-06T20:29:01.811396+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=morning-lowlands-63831.herokuapp.com request_id=e2a06890-212b-440f-9c70-ca3db2
9aea20 fwd="212.56.155.29" dyno= connect= service= status=503 bytes= protocol=https
2020-02-06T20:32:55.605806+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=morning-lowlands-63831.herokuapp.com request_id=b61eab53-2926-4a95-b008-eeae6e78370f fwd=
"212.56.155.29" dyno= connect= service= status=503 bytes= protocol=https
2020-02-06T20:32:55.830999+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=morning-lowlands-63831.herokuapp.com request_id=66fab9f1-5dd6-4465-a249-da9c4b
cc0a65 fwd="212.56.155.29" dyno= connect= service= status=503 bytes= protocol=https
2020-02-06T20:41:02.536604+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/robots.txt" host=morning-lowlands-63831.herokuapp.com request_id=e8f9bfa7-ef0f-4358-8dff-4de8c82
ad285 fwd="116.202.35.87" dyno= connect= service= status=503 bytes= protocol=http
2020-02-06T20:41:02.730170+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=morning-lowlands-63831.herokuapp.com request_id=2fc5c18d-ef41-4c10-b8b3-95e832db0ae3 fwd=
"116.202.35.87" dyno= connect= service= status=503 bytes= protocol=http
2020-02-06T20:54:36.000000+00:00 app[api]: Build started by user bajada1989@gmail.com
2020-02-06T20:54:51.845908+00:00 app[api]: Release v4 created by user bajada1989@gmail.com
2020-02-06T20:54:51.845908+00:00 app[api]: Deploy 447fd252 by user bajada1989@gmail.com
2020-02-06T20:54:52.942707+00:00 heroku[web.1]: State changed from crashed to starting
2020-02-06T20:54:52.000000+00:00 app[api]: Build succeeded
2020-02-06T20:54:54.865492+00:00 heroku[web.1]: Starting process with command `npm start`
2020-02-06T20:54:56.874344+00:00 heroku[web.1]: State changed from starting to crashed
2020-02-06T20:54:56.881443+00:00 heroku[web.1]: State changed from crashed to starting
2020-02-06T20:54:56.781760+00:00 app[web.1]: npm ERR! missing script: start
2020-02-06T20:54:56.791137+00:00 app[web.1]:
2020-02-06T20:54:56.791592+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-02-06T20:54:56.791768+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-02-06T20_54_56_782Z-debug.log
2020-02-06T20:54:56.848549+00:00 heroku[web.1]: Process exited with status 1
2020-02-06T20:54:59.003543+00:00 heroku[web.1]: Starting process with command `npm start`
2020-02-06T20:55:01.033753+00:00 heroku[web.1]: State changed from starting to crashed
2020-02-06T20:55:01.018247+00:00 heroku[web.1]: Process exited with status 1
2020-02-06T20:55:00.954857+00:00 app[web.1]: npm ERR! missing script: start
2020-02-06T20:55:00.962372+00:00 app[web.1]:
2020-02-06T20:55:00.962828+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-02-06T20:55:00.963049+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2020-02-06T20_55_00_956Z-debug.log
2020-02-06T20:55:02.251233+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=morning-lowlands-63831.herokuapp.com request_id=c6d59661-4bee-410b-898d-fe8e63dcf32e fwd=
"212.56.155.29" dyno= connect= service= status=503 bytes= protocol=https
2020-02-06T20:55:02.643620+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=morning-lowlands-63831.herokuapp.com request_id=83b388fc-ab10-4cd3-a6d5-e46318
37f525 fwd="212.56.155.29" dyno= connect= service= status=503 bytes= protocol=https

在此处输入图像描述

标签: vue.jsheroku

解决方案


推荐阅读