类型错误:未定义不是函数,js引擎:hermes

use*_*363 6 react-native metro-bundler react-native-hermes

我的 React Native (0.66.3) 应用程序今天弹出一个错误,其中的稳定代码已经很长一段时间没有任何更改了。它位于 macOS Big Sur 上。这是错误:

 ERROR  TypeError: undefined is not a function, js engine: hermes
Error: ENOENT: no such file or directory, open '/Users/macair/Documents/code/js/xyz_app5/http:/localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.xyz-app5'
    at Object.openSync (fs.js:498:3)
    at Object.readFileSync (fs.js:394:35)
    at getCodeFrame (/Users/macair/Documents/code/js/xyz_app5/node_modules/metro/src/Server.js:919:18)
    at Server._symbolicate (/Users/macair/Documents/code/js/xyz_app5/node_modules/metro/src/Server.js:992:22)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Server._processRequest (/Users/macair/Documents/code/js/xyz_app5/node_modules/metro/src/Server.js:403:7) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/Users/macair/Documents/code/js/xyz_app5/http:/localhost:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=org.reactjs.native.example.xyz-app5'
}
Run Code Online (Sandbox Code Playgroud)

这是IOS模拟器上显示的错误:

在此输入图像描述

该错误似乎与 React Native 中的 Metro 相关。

小智 0

重新安装node_modules

\n
 rm -rf node_modules \n
Run Code Online (Sandbox Code Playgroud)\n

清理你的缓存

\n
 yarn cache clean (or npm cache clean \xe2\x80\x93force)\n
Run Code Online (Sandbox Code Playgroud)\n