Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝: キャッシュに関するトラブルシュート作成 #1266

Merged
merged 10 commits into from
Oct 20, 2023
Merged
49 changes: 49 additions & 0 deletions website/docs/react-native/common-pitfalls/clear-cache.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
title: キャッシュが残ってファイルの更新ができない
---

### エラー内容
creature-water-valley marked this conversation as resolved.
Show resolved Hide resolved

イメージファイルを追加し、エミュレータで確認する時に、キャッシュが残っていると次のようなエラーが発生します。

```console
The development server returned response error
code: 500
URL: http://localhost:8081/index.bundle?platform=android&dev=true&minify=false
Body:
("originModulePath":"path/
image/Logo.tsx", targetModuleName"."assets/ logo.png
""message": "Unable to resolve module
assets/logo.pg from /path/
image/Logo.tsx: assets/logo.png could not be found within the project or in these directories:
In node_modules\n\nif you are sure the module exists, try these steps: In 1. Clear watchman
watches: watchman watch-del-all\n 2. Delete node_modules and run yarn install\n 3. Reset Metro's cache: yarn start --reset-cacheln 4. Remove the cache: rm -rf/tmp/
metro-*\n\u001b/0m\u001b|31m\u001b/1m>\u0
01b(22m\u001b[39m\u001b[90m 1 /\u001b/39m
lu001b|36mimport\u001b[39m logolmage
lu001b/36mfrom\u001b[39m \u001b|32m'assets/ logo.png'\u001b[39m\u001b|33m; lu0016/39m\u001b|0m\n\u001b|0m lu001b[90m \u001b|39m \u001b|31m\u001b(1m^\u001b[22m\u001b|
39m\u001b|0m\n\u001b|0m \u001b 90m 2 |
\u0016[39m \u001b|36mimport\u001b[39m
lu001b/33mReact\u001b 39m
\u001b|36mfrom\u001 b 39m
\u001b|32mreact\u001b(39m\u001b|33m;
```

### 対処方法

#### エミュレータの再起動

エミュレータとターミナルを終了し、再起動します。<br/>
再起動しでもエラーが発生する場合は[キャッシュ削除](/react-native/common-pitfalls/clear-cache#キャッシュ削除)を実行してください。

#### キャッシュ削除

次のコマンドでキャッシュが削除されます。

```bash
npx expo start --clear
```

:::note info
キャッシュに関する詳細は[キャッシュの取り扱い](/react-native/santoku/application-architecture/cache-management/overview/)と[Expo CLI and npm](https://docs.expo.dev/troubleshooting/clear-cache-windows/#expo-cli-and-npm)を参照してください。
creature-water-valley marked this conversation as resolved.
Show resolved Hide resolved
:::
4 changes: 4 additions & 0 deletions website/docs/react-native/common-pitfalls/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const overviews = [
{
title: 'Xcodeでビルドが失敗する',
to: '/react-native/common-pitfalls/cant-build-in-xcode',
},
{
title: 'キャッシュが残ってファイルの更新ができない',
to: '/react-native/common-pitfalls/clear-cache',
}
]

Expand Down
4 changes: 4 additions & 0 deletions website/docs/react-native/learn/todo-app/screens/logo.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,7 @@ export * from './Logo';
Welcome画面にロゴが表示されれば成功です。

![Welcome](../app-hands-on/welcome_with_logo.png)

## トラブルシュート

キャッシュの問題でエラーが発生する場合は[こちら](/react-native/common-pitfalls/clear-cache)を参考してください。
creature-water-valley marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions website/docs/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ module.exports = {
'react-native/common-pitfalls/debug-keystore-not-found',
'react-native/common-pitfalls/react-native-cli-uninstall',
'react-native/common-pitfalls/cant-build-in-xcode',
'react-native/common-pitfalls/clear-cache',
],
},
],
Expand Down
4 changes: 2 additions & 2 deletions website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ module.exports = {
to: 'react-native/santoku',
},
{
label: 'Pitfalls',
label: 'Trouble shooting',
to: 'react-native/common-pitfalls',
},
],
Expand Down Expand Up @@ -133,7 +133,7 @@ module.exports = {
to: 'react-native/santoku',
},
{
label: 'Pitfalls',
label: 'Trouble shooting',
to: 'react-native/common-pitfalls',
},
],
Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const reactNativeOverview = [
summary: <>学習用コンテンツ</>,
},
{
title: 'Common Pitfalls',
title: 'Trouble shooting',
creature-water-valley marked this conversation as resolved.
Show resolved Hide resolved
to: 'react-native/common-pitfalls',
imageUrl: 'img/undraw_void_3ggu.svg',
summary: <>ハマりがちな落とし穴</>,
Expand Down