Help us understand the problem. What is going on with this article?

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

ある日、いつものように、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

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした