首页 > 解决方案 > 无法使用本机代码创建项目

问题描述

我一直在四处寻找并已经重新安装了 node、react-native-cli 和 watchman。我正在使用模拟器,设置是:

macOS High Sierra 10.13.6
react-native: 0.57.1
node v10.11.0
watchman 4.9.0

每次我使用以下方法创建项目时:

react-native init [project_name]

我得到这个红屏:

在此处输入图像描述

我已经尝试过这个:

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-*`.
    at ModuleResolver.resolveDependency (/Users/ivofreitas/Projects/JavascriptWorkspace/react-native/YourProject/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:209:1301)

尝试使用早期版本的 react 创建,例如:

react-native init [YourProject] --version react-native@0.55.4

我再次做了这个https://facebook.github.io/react-native/docs/getting-started教程并重新安装所有内容但没有成功

标签: react-nativereact-native-ios

解决方案


我在 github 上找到了这篇文章

https://github.com/facebook/react-native/issues/21310

它通过以下方式解决问题:

npm add @babel/runtime
npm install

正如链接中所说,它不应该那样工作。


推荐阅读