将Reactjs应用程序推送到Heroku,给出了fsevents错误

时间:2018-04-09 15:33:59

标签: node.js macos reactjs heroku fsevents

我正在遵循https://blog.heroku.com/deploying-react-with-zero-configuration中提到的步骤,并且能够创建项目。但是当我尝试推送项目时,它会给我fsevents错误。这是一个全新的项目。

  1. 我在node_modules
  2. 中添加了.gitignore
  3. 我在https://github.com/angular/angular/issues/13935
  4. 中尝试了npm i -f
  5. 我已尝试将fsevents添加到optionalDependencies https://github.com/angular/angular-cli/issues/8551
  6. 这些都没有帮助我。我得到的错误:

    Building dependencies
    remote:        Installing node modules (package.json + package-lock)
    remote:        npm ERR! code EBADPLATFORM
    remote:        npm ERR! notsup Unsupported platform for fsevents@1.1.3:     wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
    remote:        npm ERR! notsup Valid OS:    darwin
    remote:        npm ERR! notsup Valid Arch:  any
    remote:        npm ERR! notsup Actual OS:   linux
    remote:        npm ERR! notsup Actual Arch: x64
    remote:        
    remote:        npm ERR! A complete log of this run can be found in:
    remote:        npm ERR!     /tmp/npmcache.y1nYC/_logs/2018-04-09T15_10_24_227Z-debug.log
    remote: 
    remote: -----> Build failed
    

    我的package.json如下

    {
      "name": "my_site",
      "version": "0.1.0",
      "private": true,
      "dependencies": {
        "react": "^16.3.1",
        "react-dom": "^16.3.1",
        "react-scripts": "1.1.4"
      },
      "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test --env=jsdom",
        "eject": "react-scripts eject"
      }
    }
    

3 个答案:

答案 0 :(得分:1)

在package.json文件中添加以下脚本后,我的构建成功。

"scripts": {
    ...
    "heroku-prebuild": "npm i -f",
    "heroku-postbuild": "npm run build"
}

答案 1 :(得分:1)

删除 react/client 文件夹中的 package-lock.json 文件对我有用。我认为 package-lock.json 包含特定于系统的设置,并且相同的设置在 Heroku 服务器上不起作用。

答案 2 :(得分:0)

将我的软件包更新为react 16.5可以为我解决此问题(运行npm update并提交更改)