error Cannot find module './assets/empty-module.js'
Require stack:
- /Users/chenmingdong/Work/workspace2reactnative/confluxdapp/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js
- /Users/chenmingdong/Work/workspace2reactnative/confluxdapp/node_modules/metro/src/node-haste/DependencyGraph.js
- /Users/chenmingdong/Work/workspace2reactnative/confluxdapp/node_modules/metro/src/Bundler.js
- /Users/chenmingdong/Work/workspace2reactnative/confluxdapp/node_modules/metro/src/IncrementalBundler.js
- /Users/chenmingdong/Work/workspace2reactnative/confluxdapp/node_modules/metro/src/index.js
- /Users/chenmingdong/Work/workspace2reactnative/confluxdapp/node_modules/@react-native-community/cli/build/commands/start/runServer.js
- /Users/chenmingdong/Work/workspace2reactnative/confluxdapp/node_modules/@react-native-community/cli/build/commands/start/start.js
- /Users/chenmingdong/Work/workspace2reactnative/confluxdapp/node_modules/@react-native-community/cli/build/commands/index.js
- /Users/chenmingdong/Work/workspace2reactnative/confluxdapp/node_modules/@react-native-community/cli/build/index.js
- /Users/chenmingdong/Work/workspace2reactnative/confluxdapp/node_modules/react-native/cli.js.
在使用 React Native 开发 IOS项目的过程中遇到的坑,用了几天都是正常的,突然就启动不了了,报上图那个错误,找了非常多的帖子都没说清楚
1、尝试过删除 node_modules 文件夹,然后重新 install (对我的项目,并没有起作用)
2、最后在一个 Github Issue 的某个回复的提示说,创建empty-module.js就可以,但是没有说在哪里创建。( Github Issues )
然后看到错误提示中Require stack的顺序下来第一句
/Users/chenmingdong/Work/workspace2reactnative/confluxdapp/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js
所以尝试了在
/Users/chenmingdong/Work/workspace2reactnative/confluxdapp/node_modules/metro/src/node-haste/DependencyGraph/目录下 assets 目录 ,然后在 assets 目录下 ,创建文件empty_module.js
然后再次启动项目 yarn start ,就成功启动了。(目前猜测是 Metro 库的一个BUG)