EXPO:无法解析模块 './debugger

Ser*_*afa 33 react-native expo

重新加载后,我的应用程序停止加载。

我已经尝试过模拟器和 2 个真正的设备,android 和 ios。

错误是:

错误:无法./debugger-ui/debuggerWorker.d9da4ed7从``解析模块:

有时我会收到错误消息,“无法找到实例”。

我尝试了以下方法:

  1. 清除守望者手表:watchman watch-del-all.
  2. 删除node_modules文件夹:rm -rf node_modules && npm install
  3. 重置 Metro Bundler 缓存:rm -rf /tmp/metro-bundler-cache-*npm start -- --reset-cache
  4. 删除加速缓存:rm -rf /tmp/haste-map-react-native-packager-*
  5. 重新启动计算机。

      Expo CLI 3.11.3 environment info:
        System:
          OS: macOS 10.15.2
          Shell: 5.7.1 - /bin/zsh
        Binaries:
          Node: 12.8.0 - ~/.nvm/versions/node/v12.8.0/bin/node
          Yarn: 1.19.1 - /usr/local/bin/yarn
          npm: 6.13.4 - ~/.nvm/versions/node/v12.8.0/bin/npm
          Watchman: 4.9.0 - /usr/local/bin/watchman
        IDEs:
          Android Studio: 3.5 AI-191.8026.42.35.5791312
          Xcode: 11.2/11B41 - /usr/bin/xcodebuild
        npmPackages:
          expo: ~36.0.0 => 36.0.2
          react: ~16.9.0 => 16.9.0
          react-native: https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz => 0.61.4
          react-navigation: ^4.0.10 => 4.0.10
        npmGlobalPackages:
          expo-cli: 3.11.3
    
    Run Code Online (Sandbox Code Playgroud)

关于我还可以尝试解决什么问题的任何想法?

完整错误如下:


Error: Unable to resolve module `./debugger-ui/debuggerWorker.d9da4ed7` from ``:

None of these files exist:
  * debugger-ui/debuggerWorker.d9da4ed7(.native|.native.expo.ts|.expo.ts|.native.expo.tsx|.expo.tsx|.native.expo.js|.expo.js|.native.expo.jsx|.expo.jsx|.native.ts|.ts|.native.tsx|.tsx|.native.js|.js|.native.jsx|.jsx|.native.json|.json|.native.wasm|.wasm)
  * debugger-ui/debuggerWorker.d9da4ed7/index(.native|.native.expo.ts|.expo.ts|.native.expo.tsx|.expo.tsx|.native.expo.js|.expo.js|.native.expo.jsx|.expo.jsx|.native.ts|.ts|.native.tsx|.tsx|.native.js|.js|.native.jsx|.jsx|.native.json|.json|.native.wasm|.wasm)
    at ModuleResolver.resolveDependency (/Users/serdarmustafa/task_location_namespace/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:163:15)
    at ResolutionRequest.resolveDependency (/Users/serdarmustafa/task_location_namespace/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:52:18)
    at DependencyGraph.resolveDependency (/Users/serdarmustafa/task_location_namespace/node_modules/metro/src/node-haste/DependencyGraph.js:282:16)
    at /Users/serdarmustafa/task_location_namespace/node_modules/metro/src/lib/transformHelpers.js:267:42
    at /Users/serdarmustafa/task_location_namespace/node_modules/metro/src/Server.js:1305:37
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/Users/serdarmustafa/task_location_namespace/node_modules/metro/src/Server.js:99:24)
    at _next (/Users/serdarmustafa/task_location_namespace/node_modules/metro/src/Server.js:119:9)
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
Run Code Online (Sandbox Code Playgroud)

Cha*_*eth 27

我通过停止调试器cmd + d&&Stop debugging然后在 chrome 中打开的调试器选项卡上进行硬重新加载alt + control + click on reload button并选择Empty cache and hard reload然后重新启动调试器来解决此错误。

  • 对于那些对“alt + control + 单击重新加载按钮”感到困惑的人,只有在使用“cmd + alt + i”打开检查器时才有效(尽管对我来说,进行硬缓存重新加载并不能解决问题) (3认同)

小智 6

通过两种方式为我解决了这个问题:

首先,我只是从提到的文件中删除了sourceMappingURL,因为这些似乎会引发错误(构建问题?)。

但由于我必须在任何软件包更新/添加上重做此操作(这非常烦人,正如您可能已经猜到的那样;),我很高兴@react-native-community/cli-debugger-ui v4.7.0昨天发布了!所以我很快将以下内容添加到我的package.json

"resolutions": {
    "@react-native-community/cli-debugger-ui": "4.7.0"
  }
Run Code Online (Sandbox Code Playgroud)

现在,在删除yarn.lock、运行npx react-native-clean-project(同样可以通过删除node_modules、清理各个构建和 Pod 来完成,但react-native-clean-project更加整洁%)并yarn再次运行,问题就消失了。

(一定要把分辨率去掉,等RN再次更新的时候……)

参考:https://github.com/react-native-community/cli/issues/1081#issuecomment-614223917

  • 很好的分享“npx react-native-clean-project”。谢谢。 (3认同)

Mon*_*tor 5

我只是遇到了同样的问题,我尝试了上面的所有答案,但出于一些奇怪的原因,没有一个对我有用。但这是对我有用的。- 删除package-lock.json和/或yarn-lock.json - 运行npm i

它像魔术一样工作。它对我有用,它可能对你不起作用,但至少尝试一下。#干杯


小智 -1

如果您安装了依赖项,但忘记安装该依赖项所需的其他依赖项,也可能会导致这种情况。例如,我安装了react-native-push-notification,但忘记安装PushNotificationIOS,并且我得到了相同的错误。