如何解决:“错误 fsevents@2.0.7:平台“linux”与此模块不兼容。”

30

我想将我的网站部署到Heroku,但是我遇到了以下错误:

error fsevents@2.0.7: The platform "linux" is incompatible with this module.
error Found incompatible module.

我已经尝试升级yarn和node,但没有帮助。我使用的是macOS Mojave v 10.14.5,而我不明白为什么这里会有linux。



remote: -----> Installing binaries
remote:        engines.node (package.json):  10.15.3
remote:        engines.npm (package.json):   unspecified (use default)
remote:        engines.yarn (package.json):  unspecified (use default)
remote:        
remote:        Resolving node version 10.15.3...
remote:        Downloading and installing node 10.15.3...
remote:        Using default npm version: 6.4.1
remote:        Resolving yarn version 1.x...
remote:        Downloading and installing yarn (1.17.3)...
remote:        Installed yarn 1.17.3
remote:        
remote: -----> Installing dependencies
remote:        Installing node modules (yarn.lock)
remote:        yarn install v1.17.3
remote:        [1/4] Resolving packages...
remote:        [2/4] Fetching packages...
error fsevents@2.0.7: The platform "linux" is incompatible with this module.
remote:        error Found incompatible module.


我被卡在同一个问题上已经一个月了,我放弃了,我真的尝试了所有可能的方法并在互联网上搜索了所有解决方案,但没有任何解决办法。所以我改用yarn。 - Joe RR
3个回答

15

yarn --ignore-platform

这将解决问题。正如名称所示,它将忽略平台(Mac/Linux)并安装这些依赖项。


7
您的回答可以通过添加有关代码功能和如何帮助提问者的更多信息来改进。 - Tyler2P
1
我非常确定应该这样使用 yarn install --ignore-engines(在此处找到示例:https://dev59.com/ilcO5IYBdhLWcg3w5lbX#45088032) - stevec
@stevec yarn命令的功能与yarn install命令相同。因此,yarn --ignore-platformyarn install --ignore-engines是等效的。 - Sougata Das

11

我删除了这些行。

fsevents@^1.2.7, fsevents@^2.0.6:
  version "2.0.7"
  resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.0.7.tgz#382c9b443c6cbac4c57187cdda23aa3bf1ccfc2a"
  integrity sha512-a7YT0SV3RB+DjYcppwVDLtn13UQnmg0SWZS7ezZD0UjnLwXmy8Zm21GMVGLaFGimIqcvyMQaOJBrop8MyOp1kQ==

  optionalDependencies:
    fsevents "^2.0.6"

来自yarn.lock,接下来我删除了

    "fsevents": "2.0.7",

package.json 文件的 resolutions 键中

最后在运行 yarn install 命令时我可以看到

info fsevents@2.0.7: The platform "linux" is incompatible with this module.
info "fsevents@2.0.7" is an optional dependency and failed compatibility check. Excluding it from installation.

success Saved lockfile.

因为此模块仅适用于MacOS,所以您不需要使用这个模块。

在Node.js中原生访问MacOS FSEvents

https://www.npmjs.com/package/fsevents


3
建议手动编辑 yarn.lock 文件吗? - Tomasz Waszczyk
1
我认为这并不是推荐的做法,但fsevents应该是可选依赖项,因为它只在Mac上需要。可能包依赖列表或yarn中存在错误。 - Daniel
2
每次执行 yarn install 后都需要执行此操作。 - Sonic Soul

3

我现在遇到了错误,但是Heroku排除了fsevents并成功地部署了。

info fsevents@2.1.3: The platform "linux" is incompatible with this module.
remote:        info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
remote:        info fsevents@1.2.13: The platform "linux" is incompatible with this module.
remote:        info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.

https://my-app.herokuapp.com/已部署到Heroku。

我没有修改yarn.lock或任何其他文件。 我最终来到这篇文章是因为我对错误感到好奇,现在我知道它只针对macOS。 换句话说,请忽略该错误并保持yarn.lock不变。


提醒一下,此建议可能适用于Heroku,但可能不适用于其他服务。在许多情况下仍然是致命错误,因此删除它或以某种方式仅在macOS或本地开发中进行条件设置(例如将其转换为devDependency,在本地使用,并在Linux上构建时使用$NODE_ENV production?)仍然是正确的修复方法,这是我的非常不谦虚的意见 :) - fool
1
很奇怪,我的经验恰好相反:在本地(macOS)没有问题,但在Heroku上出现了问题。 - stevec
@stevec 一样。有解决办法吗? - undefined
1
@RoniLitman 说实话,我记不清最终是什么解决了问题。但是,我搜索了我在上述评论时间附近的活动,找到了这个这个这个,希望其中有些东西对你有用。 - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接