在Heroku上托管React App的问题

时间:2017-09-07 08:30:58

标签: reactjs heroku create-react-app heroku-toolbelt heroku-cli

我正在尝试在heroku中托管反应应用程序......

我使用create-react-app创建了应用程序。并在托管中遵循以下方法......

        git init
        heroku create $APP_NAME --buildpack https://github.com/mars/create-react-app-buildpack.git
        git add .
        git commit -m "Start with create-react-app"
        git push heroku master
        heroku open

但是当我尝试将应用程序推送到heroku时,它会返回以下错误...

      remote:   - htmlparser.js:235 new HTMLParser
      remote:     [build_4acd980d8a80e0486da141a82d0b3cee]/[html-minifier]/src/htmlparser.js:2    35:13
      remote:   
      remote:   - htmlminifier.js:946 minify
      remote:     [build_4acd980d8a80e0486da141a82d0b3cee]/[html-minifier]/src/htmlminifier.js    :946:3
      remote:   
      remote:   - htmlminifier.js:1299 exports.minify
      remote:     [build_4acd980d8a80e0486da141a82d0b3cee]/[html-minifier]/src/htmlminifier.js    :1299:10
      remote:   
      remote:   - index.js:296 
      remote:     [build_4acd980d8a80e0486da141a82d0b3cee]/[html-webpack-plugin]/index.js:296:    16
      remote:   
      remote:   - util.js:16 tryCatcher
      remote:     [build_4acd980d8a80e0486da141a82d0b3cee]/[bluebird]/js/release/util.js:16:23  
      remote:   - promise.js:512 Promise._settlePromiseFromHandler
      remote:     [build_4acd980d8a80e0486da141a82d0b3cee]/[bluebird]/js/release/promise.js:51    2:31
      remote:   
      remote:   - promise.js:569 Promise._settlePromise
      remote:     [build_4acd980d8a80e0486da141a82d0b3cee]/[bluebird]/js/release/promise.js:56    9:18
      remote:   
      remote:   - promise.js:614 Promise._settlePromise0
      remote:     [build_4acd980d8a80e0486da141a82d0b3cee]/[bluebird]/js/release/promise.js:61    4:10
      remote:   
      remote:   - promise.js:693 Promise._settlePromises
      remote:     [build_4acd980d8a80e0486da141a82d0b3cee]/[bluebird]/js/release/promise.js:69    3:18
      remote:   
      remote:   - async.js:133 Async._drainQueue
      remote:     [build_4acd980d8a80e0486da141a82d0b3cee]/[bluebird]/js/release/async.js:133:    16
      remote:   
      remote:   - async.js:143 Async._drainQueues
      remote:     [build_4acd980d8a80e0486da141a82d0b3cee]/[bluebird]/js/release/async.js:143:    10
      remote:   
      remote:   - async.js:17 Immediate.Async.drainQueues
      remote:     [build_4acd980d8a80e0486da141a82d0b3cee]/[bluebird]/js/release/async.js:17:1    4

如何解决此问题?

1 个答案:

答案 0 :(得分:0)

我刚刚克隆了您的回购并尝试了npm install + npm run build。我发现npm run build在本地失败了。因此,这是代码的错误,而不是Heroku部署。

失败来自HTMLParser,因此我查看了public/index.html并找到了一个定制化程度很高的模板。

要检查public/index.html内容是否存在问题,我将其替换为默认的create-react-app HTML模板代码。然后,npm run build成功完成。

因此,似乎您的public/index.html 中HTML的有效性存在问题,这会破坏create-react-app的模板引擎。我建议通过HTML validator运行它来查找问题,或者手动将模板分成较小的可测试部分,直到找到导致构建错误的部分。