jest-haste-map:观看错误抱怨它无法在 jest-haste-map node_modules 文件夹中找到文件

jest-haste-map: watch error complaining that it can't find a file in the jest-haste-map node_modules folder

我刚刚升级到 RN 0.56.0 并且正在使用 jest 版本:22.4.3(更新 jest 版本没有帮助) 当我尝试 运行 我的测试套件时,我在终端中收到以下错误:

jest-haste-map: watch error: Error: ENOENT: no such file or directory, 
open '/Users/mobilepractice/builds/0bcf5ed0/0/cx-mobile/posting- 
plus/PostingPlus/node_modules/jest-haste-map/build/worker.js' at Error 
(native) at Object.fs.openSync (fs.js:640:18) at Object.fs.readFileSync 
(fs.js:508:33) at Module._extensions..js (module.js:578:20) at 
Object.require.extensions.(anonymous function) [as .js] 
(/Users/mobilepractice/builds/0bcf5ed0/0/cx-mobile/posting- 
plus/PostingPlus/node_modules/babel-register/lib/node.js:152:7) at 
Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at 
Function.Module._load (module.js:438:3) at Module.require 
(module.js:497:17) at require (internal/module.js:20:19)

还有这个错误:

/Users/mobilepractice/builds/0bcf5ed0/0/cx-mobile/posting- 
plus/PostingPlus/node_modules/react-native/jest/hasteImpl.js:50 ) /*: 
string | void */ { ^ SyntaxError: Unexpected token ) at 
Object.exports.runInThisContext (vm.js:76:16) at Module._compile 
(module.js:542:28) at Object.Module._extensions..js (module.js:579:10) 
at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at 
Function.Module._load (module.js:438:3) at Module.require 
(module.js:497:17) at require (internal/module.js:20:19) at Object. 
<anonymous> (/Users/mobilepractice/builds/0bcf5ed0/0/cx-mobile/posting- 
plus/PostingPlus/node_modules/jest-runtime/node_modules/jest-haste- 
map/build/worker.js:16:19) at next (native)

我可以在我的 node_modules 文件夹中看到 worker.js 文件,这就是 ENOENT 错误令人困惑的原因。

一个解决方案是确保安装了节点 8 或更高版本。此错误发生在节点 6.9.1.