LoginSignup
13
5

More than 3 years have passed since last update.

ReactNativeでUnable to resolve module expo from ~が出た

Last updated at Posted at 2019-09-06

ある日、いつものように、ReactNativeでプロジェクトを作って
run-iosで実行しようとしたところ、こんなエラーが出てしまった。

Unable to resolve module `expo` from `/XXXX/YYYYYYYY/reactNative/nearToilet/App.js`: Module `expo` does not exist in the Haste module map

This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try 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-*`.

試したこと

エラーが出ているプロジェクトを
rm -rf ***
で削除したが、状況変わらず。

エラーに書いてある
To resolve try the following:
の下に書いてあるコマンドを一通り試したが、効果はなかったようだ。

状況が変わった?!

run-iosで開いていたターミナルを閉じたら、エラーが変わった。

No bundle URL present.

Make sure you're running a packager server or have included a .jsbundle file in your application bundle.

こちらの記事が参考になった
https://qiita.com/kondoakio/items/8b5ef1d1abe2b016dc9e

記事の通りにキャッシュを削除するコマンド

./node_modules/react-native/scripts/packager.sh --reset-cache

するとこんなのが、出現するので少し待つ

┌──────────────────────────────────────────────────────────────────────────────┐
│                                                                              │
│  Running Metro Bundler on port 8081.                                         │
│                                                                              │
│  Keep Metro running while developing on any JS projects. Feel free to        │
│  close this tab and run your own Metro instance if you prefer.               │
│                                                                              │
│  https://github.com/facebook/react-native                                    │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘

Looking for JS files in
   /Users/tnatsume/reactNative_new/newsmyLocation 

warning: the transform cache was reset.
Loading dependency graph, done.

んで、もう一回

react-native run-ios

を打ったら、無事にプロジェクトを表示させることができた✌️

13
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
5