尝试将laravel项目部署到heroku时出现应用程序错误

chhqkbe1  于 2023-02-13  发布在  其他
关注(0)|答案(1)|浏览(127)

我上传了我的Laravel项目在虚拟主机Heroku,但它不工作,它说:Application error An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command heroku logs --tail当我在cmd中运行命令heroku logs --tail时,它显示:
看起来错误甚至不止一个,我真的不知道这些错误意味着什么,我在任何地方都找不到它们。

2023-02-10T20:33:34.785966+00:00 heroku[web.1]: State changed from starting to crashed
2023-02-10T20:34:07.000000+00:00 app[api]: Build succeeded
2023-02-10T20:34:07.404549+00:00 heroku[web.1]: State changed from crashed to starting
2023-02-10T20:34:10.304458+00:00 heroku[web.1]: Starting process with command `npm start`
2023-02-10T20:34:12.223124+00:00 app[web.1]:
2023-02-10T20:34:12.223146+00:00 app[web.1]: > start
2023-02-10T20:34:12.223147+00:00 app[web.1]: > if-env NODE_ENV=production && npm run start:prod || npm run start:dev
2023-02-10T20:34:12.223147+00:00 app[web.1]:
2023-02-10T20:34:12.228492+00:00 app[web.1]: sh: 1: if-env: not found
2023-02-10T20:34:12.626616+00:00 app[web.1]:
2023-02-10T20:34:12.626644+00:00 app[web.1]: > start:dev
2023-02-10T20:34:12.626646+00:00 app[web.1]: > concurrently "nodemon - -ignore 'client/*'" "npm run client"
2023-02-10T20:34:12.626646+00:00 app[web.1]:
2023-02-10T20:34:12.632186+00:00 app[web.1]: sh: 1: concurrently: not found
2023-02-10T20:34:12.794122+00:00 heroku[web.1]: Process exited with status 127
2023-02-10T20:34:12.856093+00:00 heroku[web.1]: State changed from starting to crashed
2023-02-10T20:34:14.498753+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=poradej-turnaj.herokuapp.com request_id=dbc569cd-b37e-4a45-a8cb-8e791fa59c1c fwd="84.42.219.107" dyno= connect= service= status=503 bytes= protocol=https
2023-02-10T20:34:14.675679+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=poradej-turnaj.herokuapp.com request_id=5476f6cb-67c8-4f2e-a5e2-abdbfc923cc2 fwd="84.42.219.107" dyno= connect= service= status=503 bytes= protocol=https

这里我张贴我的一些代码:package.json

{
    "private": true,
    "scripts": {    
        "start": "if-env NODE_ENV=production && npm run start:prod || npm run start:dev", 
        "start:prod": "node server.js", 
        "start:dev": "concurrently \"nodemon - -ignore 'client/*'\" \"npm run client\""
    },
    "devDependencies": {
        "@popperjs/core": "^2.11.6",
        "axios": "^0.27",
        "bootstrap": "^5.2.3",
        "laravel-vite-plugin": "^0.6.0",
        "lodash": "^4.17.19",
        "postcss": "^8.1.14",
        "sass": "^1.56.1",
        "vite": "^3.0.0"
    },
    "engines": {
        "npm": "9.4.2",
        "node": "18.13.0"
    },
    "dependencies": {
        "nodemon": "^2.0.20"
    }
}

过程文件

web: vendor/bin/heroku-php-apache2 public/

你能给予我一些建议吗?告诉我是否应该发布更多代码

piwo6bdm

piwo6bdm1#

看起来有两个命令行实用程序根本不存在。if-envconcurrently。如果你看一下package.json中的脚本,你就会明白我的意思。服务器试图运行这些命令,但实用程序不存在。
因此,您需要将它们安装在Heroku服务器上,或者找到一种方法来更改前端应用程序的启动方式。
https://www.npmjs.com/package/if-env
https://www.npmjs.com/package/concurrently
我真的不知道为什么你的服务器会运行这些脚本,通常服务器从Github下载代码,运行npm build(或其他),然后简单地服务于编译好的js。
我不知道关于Heroku的任何事情。

相关问题