如何初始化 React Native 项目 [英] How to initialize React Native project
问题描述
请注意,我已阅读文档,并参考了发生错误的点以及我采取的步骤.请不要建议我遵循我已经表明已遵循的说明.
Please note I have read the documentation and I'm referencing the point where the error happens as well as the steps I have taken. Please don't advice me to follow the instructions that I have already indicated I have followed.
在遵循 React Native 的 文档 之后,最好以我的能力,我一直无法让 React Native 运行.我已经按照说明安装了 jdk、node 和 Android Studio(使用 Chocolatey 和链接).Android 模拟器从 Android Studio 运行.我使用的是 npm 版本 6.1.0、节点版本 8.4.0、jdk 8、Android Studio 3.1.3.我在 react-native init AwesomeProject
之后得到的错误是 SyntaxError: Unexpected token import
.我做错了什么?我怎样才能解决这个问题?运行 react-native run-android
也会出现同样的错误.
After following the documentation of React Native to the best of my ability, I have been unable to get React Native to run. I have installed jdk, node, and Android Studio as instructed (using Chocolatey and links). The Android Emulator runs from Android Studio. I'm using npm version 6.1.0, node version 8.4.0, jdk 8, Android Studio 3.1.3. The error I get after react-native init AwesomeProject
is SyntaxError: Unexpected token import
. What did I do wrong? How can I fix this? Running react-native run-android
also gives the same error.
要清楚,我在正确的目录中.ANDROID_HOME
设置为正确的 sdk
文件夹.有一个标题,运行你的 React Native 应用程序
,运行第一个命令会给我留下错误,但在那之前我没有收到错误.
To be clear, I'm in the proper directory. ANDROID_HOME
is set to the proper sdk
folder. There is a heading, Running your React Native application
, and running the first command leaves me with the error, but I don't get an error before that point.
推荐答案
- 安装 npm
- 安装 react native cli => npm install -g
react-native-cli &&npm install -g react-native (admin 或 sudo)
- install npm
- install react native cli => npm install -g
react-native-cli && npm install -g react-native (admin or sudo)
- react-native 初始化 MyProject
- cd Myproject
- react-native run-ios 或 run-android
这篇关于如何初始化 React Native 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!