[英]Error: fsEvents is not a function (using Jest and create-react-app)
当我运行 npm test 时,我不断收到错误“fsEvents 不是函数”
package.json 中的片段
"test": "react-scripts test"
运行 npm test 时出错
TypeError: fsevents is not a function
at new FSEventsWatcher (node_modules/jest-runtime/node_modules/jest-haste-map/build/lib/FSEventsWatcher.js:162:20)
at createWatcher (node_modules/jest-runtime/node_modules/jest-haste-map/build/index.js:1052:23)
at Array.map (<anonymous>)
at HasteMap._watch (node_modules/jest-runtime/node_modules/jest-haste-map/build/index.js:1230:44)
at node_modules/jest-runtime/node_modules/jest-haste-map/build/index.js:517:21
at Generator.next (<anonymous>)
at asyncGeneratorStep (node_modules/jest-runtime/node_modules/jest-haste-map/build/index.js:193:24)
at _next (node_modules/jest-runtime/node_modules/jest-haste-map/build/index.js:213:9)
React 脚本版本:3.0.1(也尝试过 3.4.0)节点版本:v12.16.1 npm 版本:4.6.1
我曾尝试更改 Node 的版本(降级、升级到最新版本)- 不起作用,还根据另一篇文章的建议将 npm 降级到 4.x- 不起作用。 还尝试安装最新版本的 Chokidar(我不需要它作为项目中的依赖项)。
可能是什么问题?
我在反应脚本版本 3.3.0 上遇到了同样的问题。 标准的东西都不起作用,包括尝试将 fsevents 降级到早期版本。 最后执行npm audit fix --force
来审计和修复可能的安全问题,从而解决了上述问题。
由于npm audit fix --force
可能会修改您的依赖链,请在单独的分支上执行和测试
希望这可以帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.