ReactNative might be related to https://github.com/facebook/react-native/issues/4968
1. 摘要
ReactNative在開發的時候,會遇到很多坑。需要我們根據日誌來解決。把解決經過記錄下來,方便之後的開發人員來搜尋解決辦法。
2. 日誌
Loading dependency graph, done.
error: bundling: UnableToResolveError: Unable to resolve module `react/lib/ReactDebugCurrentFrame` from `/Users/afunx/Code/reactive/dn/rn_project/node_modules/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js`: Module does not exist in the module map or in these directories:
/Users/afunx/Code/reactive/dn/rn_project/node_modules/react/lib
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 packager cache: `rm -fr $TMPDIR/react-*` or `npm start --reset-cache`.
at p.catch.error (/Users/afunx/Code/reactive/dn/rn_project/node_modules/react-native/packager/src/node-haste/DependencyGraph/ResolutionRequest.js:366:19)
at process._tickCallback (internal/process/next_tick.js:109:7)
Bundling `index.android.js` 99.5% (398/399), failed.
3. 解決辦法
- 刪除
node_modules
資料夾:rm -rf node_modules && npm install
- 重置 packager cache:
或者:rm -fr $TMPDIR/react-*
node_modules/react-native/packager/packager.sh --reset-cache
- 清除 watchman watches:
watchman watch-del-all
- Recreate the project from scratch:
react-native run-android