EXPO: Unable to resolve module ‘./debugger

我怕爱的太早我们不能终老 提交于 2020-06-24 11:05:32

问题


After a reload my app has stopped loading.

I have tried on both emulators and 2 real devives, android and ios.

The error is:

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

and occassionally I will get the error, 'unable to locate instance'.

I have tried the following:

  1. Clear watchman watches: watchman watch-del-all .
  2. Delete the node_modules folder: rm -rf node_modules && npm install .
  3. Reset Metro Bundler cache: rm -rf /tmp/metro-bundler-cache-* or npm start -- --reset-cache .
  4. Remove haste cache: rm -rf /tmp/haste-map-react-native-packager-* .
  5. Restart the computer.

      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
    

Any ideas on what else I can try to resolve this?

The full error below:


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)

回答1:


Check your npm version in package.json.

"dependencies": {
    "@react-native-firebase/app": "^6.0.0",
    "@react-native-firebase/auth": "^6.0.0",
    "acorn": "^7.0.0",
    "axios": "^0.19.1",
    "expo-web-browser": "^8.0.0",
    "i": "^0.3.6",
    "loadash": "^1.0.0",
    "npm": "^6.11.3",

In my case, I did npm update and my npm version in dependecy moved to the latest version which caused breaking changes




回答2:


I solved this error by stopping the debugger cmd + d && Stop debugging then doing a hard reload on the open debugger tab in chrome alt + control + click on reload button and choose Empty cache and hard reload then restart debugger.




回答3:


I just had the same issue and I tried all the answer above, for some strange reasons none worked for me. But here is what worked for me. - Delete the package-lock.json and/or yarn-lock.json - run npm i

it worked like magic. it worked for me, it might not work for you but at least give it try. #cheers




回答4:


This can also be caused if you install a dependency, but forget to install other dependencies needed for that dependency. For example, I installed react-native-push-notification, but forgot to install PushNotificationIOS, and I got an identical error.




回答5:


This can also happen if you moved your code modules into another directory like /src in order to take advantage of absolute path imports by using the module-resolver plugin in babel.config




回答6:


Solved it for me in two ways:

First I simply removed the sourceMappingURL from the mentioned files, as these seemed to raise the error (build problems?).

But as I had to redo this on any package update / addition (which got quite annoying, as you might have guessed ; ), I was quite happy that @react-native-community/cli-debugger-ui v4.7.0 has been released yesterday! So I quickly added the following to my package.json:

"resolutions": {
    "@react-native-community/cli-debugger-ui": "4.7.0"
  }

Now, after deleting yarn.lock, running npx react-native-clean-project (the same could have been accomplished by deleting node_modules, cleaning the individual builds & pods, but react-native-clean-project is so much neater % ) & running yarn again, the problem was gone.

(Be sure to remove the resolution, when RN updates again...)

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




回答7:


I resovled this error by removing node modules + yarn.lock in project



来源:https://stackoverflow.com/questions/59658998/expo-unable-to-resolve-module-debugger

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!