【问题标题】:Heroku Nodejs - React error deploying appHeroku Nodejs - 部署应用程序时反应错误
【发布时间】:2021-06-23 22:41:55
【问题描述】:

大家好,我正在尝试在 Heroku 上部署一个 React-node 应用程序,这是 heroku 的控制台日志:

-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
-----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 14.x...
       Downloading and installing node 14.17.1...
       Using default npm version: 6.14.13
       
-----> Installing dependencies
       Installing node modules
       npm ERR! bindings not accessible from watchpack-chokidar2:fsevents
       
       npm ERR! A complete log of this run can be found in:
       npm ERR!     /tmp/npmcache.5mYJI/_logs/2021-06-23T22_19_01_465Z-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
       
       Some possible problems:
       
       - Node version not specified in package.json
         https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
       
       Love,
       Heroku
       
 !     Push rejected, failed to compile Node.js app.
 !     Push failed

这是我的存储库: https://github.com/aadiegoaa96/reactporfolioDiego Heroku 应用链接: https://reactporfoliodnbc.herokuapp.com/

感谢大家的支持。

【问题讨论】:

  • 由于 npm6 CI 无法读取 npm 7 package-lock.json,我遇到了类似的错误

标签: reactjs heroku


【解决方案1】:

我有类似的问题。 删除package-lock.json 文件解决了这个问题。

【讨论】:

    【解决方案2】:

    当我发现我的本地 npm 版本不适合 Heroku 中的 npm 版本时,我已经解决了这个问题。 我需要在我的 Heroku 环境中添加与本地版本相同的 npm 版本,就像在 package.json 中这样:

    {
    "engines":{
    "node":"yournodeversion",
    "npm":"yournpmversion"
    }
    }
    

    【讨论】:

      【解决方案3】:

      使用 Heroku 的 create-react-app buildpack 可以解决这个问题。

      目前,您的 react-app 被视为常规 node.js 应用程序,因为使用了 node.js 构建包,由于根目录中存在 package.json 而自动推断。

      CRA 构建包:https://elements.heroku.com/buildpacks/nhutphuongit/create-react-app-buildpack

      (类似 Q)-React Application on Heroku

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-09-22
        • 1970-01-01
        • 1970-01-01
        • 2012-02-20
        • 1970-01-01
        • 1970-01-01
        • 2016-09-10
        • 2017-02-09
        相关资源
        最近更新 更多