今天调试demo遇到一个问题,使用react-native run-ios命令启动app,在加载bundle的时候,本地package 服务报了如下错误:
报错
···
Error: Unable to resolve module ./debugger-ui/debuggerWorker.js
from ``:
None of these files exist:
- debugger-ui/debuggerWorker.js(.native|.native.js|.js|.native.json|.json|.native.ts|.ts|.native.tsx|.tsx)
- debugger-ui/debuggerWorker.js/index(.native|.native.js|.js|.native.json|.json|.native.ts|.ts|.native.tsx|.tsx)
at ModuleResolver.resolveDependency (/Users/fantuan/RnDemo/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:163:15)
at ResolutionRequest.resolveDependency (/Users/fantuan/RnDemo/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:52:18)
at DependencyGraph.resolveDependency (/Users/fantuan/RnDemo/node_modules/metro/src/node-haste/DependencyGraph.js:287:16)
at /Users/fantuan/RnDemo/node_modules/metro/src/lib/transformHelpers.js:267:42
at Server.<anonymous> (/Users/fantuan/RnDemo/node_modules/metro/src/Server.js:841:41)
at Generator.next (<anonymous>)
at asyncGeneratorStep (/Users/fantuan/RnDemo/node_modules/metro/src/Server.js:99:24)
at _next (/Users/fantuan/RnDemo/node_modules/metro/src/Server.js:119:9)
[Fri Sep 25 2020 12:45:39.478] BUNDLE ./index.js
···
在React-Native官网的issues中发现了对应的问题,但是下面的反馈来看,大部分都是说rn的版本问题,当前我的demo的版本也是0.62.2
"react": "16.11.0",
"react-native": "0.62.2",
解决方案
打开React Native Debug Menu 页面,重新关闭打开debug就可以了。