我按照以下链接开始使用react-native
Getting started with react native
我尝试在没有博览会的情况下创建 native 应用程序 所以我根据文档我遵循了以下命令
npm install -g react-native-cli
react-native init AwesomeProject
运行android命令后
react-native run-android
它在模拟器上给了我以下错误
所以我使用启动命令来运行 Metro 服务器
react-native start
这个命令在控制台中给了我另一个错误
请您参考如下方法:
使用某些 NPM 和 Node 版本的 Metro 存在问题。
你有两种选择:
- 替代方案 1:卸载 node 和 npm 并使用另一个(兼容)版本重新安装: https://nodejs.org/en/download
- 替代方案 2:转到 npde_modules 文件夹中的文件:
\node_modules\metro-config\src\defaults\blacklist.js并更改此代码:
var sharedBlacklist = [
/node_modules[/\\]react[/\\]dist[/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
对此:
var sharedBlacklist = [
/node_modules[\/\\]react[\/\\]dist[\/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
Please note that if you run
npm installoryarn installyou'll need to change the code again.






