【问题标题】:! Push rejected, failed to compile Node.js app. ! Push failed!推送被拒绝,无法编译 Node.js 应用程序。 !推送失败
【发布时间】:2020-06-05 09:40:04
【问题描述】:

我一直在尝试将我的 react 网站推送到 heroku,但它不会让我成功,但我已成功将其推送到 github。我也更新了我的节点版本,但似乎没有任何效果。这个网站上有关于同一问题的类似问题,我也按照他们的步骤进行操作,但似乎没有任何效果

sh: 1: ng: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! portfolio@1.0.0 heroku-postbuild: `ng build --prod`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the portfolio@1.0.0 heroku-postbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     /tmp/npmcache.XmdM7/_logs/2020-02-21T00_18_42_925Z-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


here's my package.json file

{
  "name": "portfolio",
  "version": "1.0.0",
  "engines": {
    "node": "12.16.1",
    "npm": "6.13.4"
  },
  "description": "A clean, beautiful and responsive portfolio template for Developers!",
  "main": "index.js",
  "scripts": {
    "start": "webpack-dev-server --config webpack.dev.js --open",
    "build": "webpack --config webpack.prod.js",
    "heroku-postbuild": "ng build --prod"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/mkhawark/portfolio.git"
  },
  "keywords": [],
  "author": "Mohammad Khawar",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/mkhawark/portfolio/issues"
  },
  "homepage": "https://github.com/mkhawark/portfolio#readme",
  "devDependencies": {
    "clean-webpack-plugin": "^3.0.0",
    "css-loader": "^3.4.1",
    "file-loader": "^5.0.2",
    "html-loader": "^0.5.5",
    "html-webpack-plugin": "^3.2.0",
    "mini-css-extract-plugin": "^0.9.0",
    "node-sass": "^4.13.0",
    "optimize-css-assets-webpack-plugin": "^5.0.3",
    "sass-loader": "^8.0.0",
    "style-loader": "^1.1.2",
    "webpack": "^4.41.5",
    "webpack-cli": "^3.3.10",
    "webpack-dev-server": "^3.10.1",
    "webpack-merge": "^4.2.2"
  },
  "dependencies": {
    "bootstrap": "^4.4.1",
    "jquery": "^3.4.1",
    "popper.js": "^1.16.0",
    "tilt.js": "^1.2.1"
  }
}

【问题讨论】:

    标签: node.js reactjs heroku npm


    【解决方案1】:

    你读过这个吗:https://devcenter.heroku.com/articles/getting-started-with-nodejs

    看起来您的启动脚本只是在启动开发服务器,但使用 heroku 您必须提供实际的构建文件。

    您必须构建项目,然后使用简单的服务器为构建文件夹提供静态服务。这是我的一个项目中的示例设置,请注意 npm start 只会触发快速服务器 index.js:https://github.com/mattberg88/genome-project/tree/heroku

    【讨论】:

      【解决方案2】:

      您可以通过将node_modules 添加到您的.gitignore 页面来解决此问题。您可以查看此链接了解更多信息:Fail to deploy node.js application to heroku

      让我知道这是否适合你:)

      【讨论】:

        猜你喜欢
        • 2018-12-16
        • 1970-01-01
        • 2023-03-23
        • 2018-07-01
        • 2020-09-24
        • 1970-01-01
        • 2016-01-10
        • 2015-02-19
        • 2014-05-24
        相关资源
        最近更新 更多