【问题标题】:Heroku build failed after a successful deployment成功部署后 Heroku 构建失败
【发布时间】:2020-12-29 18:49:48
【问题描述】:

我定期部署到 Heroku,过去一切正常。然后,在仅更改一行代码并将其推送到 Heroku 之后失败了。

我没有更新或安装任何东西。这种行为对我来说似乎太奇怪了。

\-----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       NODE_VERBOSE=false
       
-----> Installing binaries
       engines.node (package.json):  12.18.1
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 12.18.1...
       Downloading and installing node 12.18.1...
       Using default npm version: 6.14.5
       
-----> Restoring cache
       - node_modules
       
-----> Installing dependencies
       Installing node modules
       
       > fsevents@1.2.9 install /tmp/build_afdd9f79/node_modules/fsevents
       > node install
       
       npm ERR! Cannot read property 'length' of undefined
       
       npm ERR! A complete log of this run can be found in:
       npm ERR!     /tmp/npmcache.Lt04X/_logs/2020-09-10T20_50_40_685Z-debug.log
-----> Build failed
       
       We're sorry this build is failing! You can troubleshoot common issues here:
       https://devcenter.heroku.com/articles/troubleshooting-node-deploys
       
       If you're stuck, please submit a ticket so we can help:
       https://help.heroku.com/
       
       Love,
       Heroku
       
 !     Push rejected, failed to compile Node.js app.
 !     Push failed

package.json 如下:

{
    "private": true,
    "scripts": {
        "dev": "npm run development",
        "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch": "npm run development -- --watch",
        "watch-poll": "npm run watch -- --watch-poll",
        "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
        "prod": "npm run production",
        "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "build": "npm run production",
        "postinstall": "npm run prod",
        "heroku-postbuild": "npm run prod"
    },
    "devDependencies": {
        "axios": "^0.19.2",
        "bootstrap": "^4.5.0",
        "browser-sync": "^2.26.7",
        "browser-sync-webpack-plugin": "^2.2.2",
        "cross-env": "^5.1",
        "jquery": "^3.5.1",
        "laravel-mix": "^4.0.7",
        "lodash": "^4.17.13",
        "popper.js": "^1.16.1",
        "resolve-url-loader": "^2.3.1",
        "sass": "^1.26.9",
        "sass-loader": "7.*",
        "vue": "^2.6.11",
        "vue-template-compiler": "^2.6.11"
    },
    "dependencies": {
        "@chenfengyuan/vue-number-input": "^1.2.1",
        "country-list": "^2.2.0",
        "moment": "^2.27.0",
        "vue-cool-lightbox": "^2.5.1",
        "vue-loading-overlay": "^3.3.2",
        "vue-moment": "^4.1.0",
        "vue-recaptcha": "^1.3.0",
        "vue-resource": "^1.5.1",
        "vue-router": "^3.3.4",
        "vue-select": "^3.10.3",
        "vue-stripe-elements-plus": "^0.3.2",
        "vuex": "^3.4.0"
    },
    "engines": {
        "node": "12.18.1"
    }
}

这可能是什么原因?

【问题讨论】:

  • 我今天也看到了这个问题。
  • 不是您的问题的解决方案,但是将 npm 换成 yarn 使我们的构建克服了这次失败。
  • 完成了这项工作。
  • 花费数小时后。纱线有效!

标签: heroku deployment package.json


【解决方案1】:

虽然不是严格意义上的问题解决方案,但我能够通过将项目迁移到 Yarn 来克服这个错误。

【讨论】:

    【解决方案2】:

    我通过消除“postinstall”脚本并仅使用这一行来使其工作:

    "heroku-postbuild": "npm 运行生产"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-22
      • 1970-01-01
      • 1970-01-01
      • 2020-10-09
      • 1970-01-01
      • 2019-03-05
      • 2022-10-05
      • 1970-01-01
      相关资源
      最近更新 更多