解决mac下fsevents.watch is not a function错误

10 阅读1分钟

背景:

  • 系统 macos
  • 使用cra 启动项目时,

fsevents是什么

Native access to MacOS FSEvents in Node.js

错误原因: ~/node_modules目录下使用的fsevents版本是1.x的,导出方法如下: module.exports = watch; 而2.x导出的方法如下: exports.watch = watch;

解决方法: 在~/node_modules目录下执行npm install fsevents, 更新到最新版本。