【问题标题】:heroku launches build and gets stuckheroku 启动构建并卡住
【发布时间】:2022-08-05 23:54:52
【问题描述】:

日志:

.\\yoshi-realese> git push heroku master
Enumerating objects: 2449, done.
Counting objects: 100% (2449/2449), done.
Delta compression using up to 16 threads
Compressing objects: 100% (2353/2353), done.
Writing objects: 100% (2449/2449), 4.63 MiB | 2.71 MiB/s, done.
Total 2449 (delta 275), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote: -----> Building on the Heroku-20 stack
remote: -----> Determining which buildpack to use for this app
remote: -----> Node.js app detected
remote: -----> Build
remote:        Running build
remote:        > yoshi-v1@1.0.0 build
remote:        > nodemon app.js
remote:        [nodemon] 2.0.19
remote:        [nodemon] to restart at any time, enter `rs`
remote:        [nodemon] watching path(s): *.*
remote:        [nodemon] watching extensions: js,mjs,json
remote:        [nodemon] starting `node app.js`
remote:        started yoshistore

之后什么也没有发生。

这是我的package.json

{
  \"name\": \"yoshi-v1\",
  \"version\": \"1.0.0\",
  \"description\": \"\",
  \"main\": \"app.js\",
  \"scripts\": {
    \"build\": \"nodemon app.js\",
    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"
  },
  \"author\": \"\",
  \"license\": \"ISC\",
  \"dependencies\": {
    \"@handlebars/allow-prototype-access\": \"^1.0.5\",
    \"express\": \"^4.18.1\",
    \"express-handlebars\": \"^6.0.6\",
    \"handlebars\": \"^4.7.7\",
    \"mongoose\": \"^6.5.1\",
    \"nodemon\": \"^2.0.19\"
  }
}

Screenshot

  • 你期望会发生什么?
  • 在构建之后,应该会进行压缩和启动。一切完成后,控制台中将出现一个指向该站点的链接
  • 稍后在 heroku 日志中有一行 -----> Timed out running buildpack Node.js
  • 请告诉我们您的package.json。我怀疑您的构建脚本正在尝试实际运行您的应用程序。
  • { \"name\": \"yoshi-v1\", \"version\": \"1.0.0\", \"description\": \"\", \"main\": \"app. js\", \"scripts\": { \"build\": \"nodemon app.js\", \"test\": \"echo \\\"错误:没有指定测试\\\" && 退出1\" }, \"author\": \"\", \"license\": \"ISC\", \"dependencies\": { \"@handlebars/allow-prototype-access\": \" ^1.0.5\", \"express\": \"^4.18.1\", \"express-handlebars\": \"^6.0.6\", \"handlebars\": \"^4.7. 7\", \"猫鼬\": \"^6.5.1\", \"nodemon\": \"^2.0.19\" } }

标签: git heroku


【解决方案1】:

您的构建脚本尝试运行您的应用程序:

"build": "nodemon app.js"

那不是它的用途。当 Heroku 构建您的应用程序时,构建脚本在每次部署时运行一次,以生成您的应用程序需要的任何工件。

这可能涉及将 TypeScript 编译为 JavaScript、缩小代码、摇树或一大堆其他事情。我不确定你的应该是什么,但你可以尝试完全忽略它。

您的应用程序,Heroku 将查看您的Procfile。如果不存在这样的文件,it will run your start script as a web process。尝试相应地更改您的package.json

"scripts": {
  "start": "node app.js",
  "test": "echo \"Error: no test specified\" && exit 1"
}

在这里,我将build 更改为start,并将nodemon(这是一个不应在生产中使用的开发工具)替换为node

【讨论】:

    猜你喜欢
    • 2021-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-17
    • 2023-04-04
    相关资源
    最近更新 更多