运行yarn后,Mac book更新后get fsevents命令失败

Jos*_*nus 7 react-native

MacBook 更新到 v12.4 后,当我尝试在 React Native 项目上运行 YARN 命令时,出现此错误:

error /Users/jaugustinus/Documents/Dev/Service-Bay/node_modules/fsevents: Command failed.
Exit code: 1
Command: node install.js
Arguments: 
Directory: /Users/jaugustinus/Documents/Dev/Service-Bay/node_modules/fsevents
Output:
node:events:505
      throw er; // Unhandled 'error' event
      ^

Error: spawn node-gyp ENOENT
    at Process.ChildProcess._handle.onexit (node:internal/child_process:283:19)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (node:internal/child_process:289:12)
    at onErrorNT (node:internal/child_process:478:16)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawn node-gyp',
  path: 'node-gyp',

Run Code Online (Sandbox Code Playgroud)

该命令昨天运行良好,唯一的变化是 Mac 操作系统更新。

也尝试过运行

rm -rf node_modules
yarn cache clean
yarn
Run Code Online (Sandbox Code Playgroud)

仍然遇到同样的错误

小智 18

将项目的节点版本升级到 20.3 后得到此信息。事实证明,修复是为了确保 node-gyp 本身是最新的:

yarn global add node-gyp
Run Code Online (Sandbox Code Playgroud)

这样做之后,我的原创yarn install就成功了。


Jos*_*nus 1

我遇到的错误是使用节点版本 16.15.0 时

如果我将节点版本更改为 17.8.0,那么我就可以毫无问题地运行纱线。