简体   繁体   English

无法在 web 浏览器中运行此 React Native 示例

[英]Cannot run this React Native example in web browser

Code example I am trying to run: https://github.com/nshaposhnik/react-native-maps-example我正在尝试运行的代码示例: https://github.com/nshaposhnik/react-native-maps-example

I am on windows 10.我在 windows 10。

What I do:我所做的:

  • Downloaded the code下载了代码

  • Extracted to folder解压到文件夹

  • Setup with the following after deleting yarn.lock:删除 yarn.lock 后设置如下:

    yarn add react-native-maps纱线添加反应原生地图

    yarn add react-native-maps-directions yarn add react-native-maps-directions

    yarn add react-native-google-places-autocomplete yarn add react-native-google-places-autocomplete

    npm install npm安装

    npm audit fix npm 审计修复

  • Edit the code in the 3 places that requires my custom google API key which I got from the developer site在需要我从开发人员网站获得的自定义 google API 密钥的 3 个地方编辑代码

  • Tried running via:尝试通过以下方式运行:

    npm start npm启动

I get a successful run in the terminal (" Welcome to React Native, Learn once, write anywhere").我在终端中成功运行(“欢迎使用 React Native,学习一次,随处编写”)。 but no browser opens up.但没有打开浏览器。 I go to localhost:8081 in my browser and see a barren webpage with the following text:我在浏览器中将 go 转到localhost:8081并看到一个带有以下文本的空白网页:

React Native packager is running.

Visit documentation

That's all.就这样。 Nothing in the sample project runs.示例项目中没有任何内容运行。 I just want to run their app in a browser or emulator, though I don't have any of the phone emulators working, so I just want to run in web browser.我只想在浏览器或模拟器中运行他们的应用程序,虽然我没有任何手机模拟器工作,所以我只想在 web 浏览器中运行。

How can I make this work from the above example?我怎样才能从上面的例子中完成这项工作? Much appreciated.非常感激。

You have to run emulator separately on "Windows" using android studio or command line, and after open your project using VsCode(or your editor) and the run following command,您必须使用 android 工作室或命令行在“Windows”上单独运行模拟器,然后使用 VsCode(或您的编辑器)打开您的项目并运行以下命令,

react-native run-android react-native run-android

Your app will run on your opened emulator您的应用程序将在您打开的模拟器上运行

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM