【问题标题】:Push Reactjs app to Heroku giving fsevents error将 Reactjs 应用程序推送到 Heroku 给出 fsevents 错误
【发布时间】:2018-09-19 01:40:51
【问题描述】:

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

  1. 我在.gitignore 中添加了node_modules
  2. 我已经尝试过npm i -f,如https://github.com/angular/angular/issues/13935
  3. 我已尝试将fsevents 添加到optionalDependencies,如https://github.com/angular/angular-cli/issues/8551 中所述

这些都没有帮助我。我得到的错误:

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"
  }
}

【问题讨论】:

  • 有趣,我也发生了同样的事情

标签: node.js macos reactjs heroku fsevents


【解决方案1】:

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

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

【讨论】:

  • 这适用于 laravel/vue js
【解决方案2】:

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

【讨论】:

    【解决方案3】:

    将我的包更新到 react 16.5 为我解决了这个问题(运行 npm update 并提交了更改)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-01
      • 2021-04-03
      • 1970-01-01
      • 2021-11-22
      • 2022-09-25
      • 2019-05-12
      • 1970-01-01
      • 2010-12-30
      相关资源
      最近更新 更多