创建新的React Native应用程序

问题描述 投票:2回答:3

我在创建我的第一个反应原生应用程序时遇到错误。我正在使用以下指南 - https://facebook.github.io/react-native/docs/getting-started.html

https://github.com/react-community/create-react-native-app

$ npm install -g create-react-native-app
--Worked fine
$ create-react-native-app my-first-native-app
--app created without errors
$ npm start
--gives error

Error: React native is not installed. Please run `npm install` in your project directory.
1:09:05: Error starting packager: Error: Couldn't start project. Please fix the errors and restart the project.
    at C:\xdl\src\Project.js:1329:11
    at Generator.next (<anonymous>)
    at step (C:\reactJs-projects\my-first-native-app\node_modules\xdl\build\Project.js:1735:191)
    at C:\reactJs-projects\my-first-native-app\node_modules\xdl\build\Project.js:1735:361
    at <anonymous>
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `react-native-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

试图通过降级npm到版本4进行修复,因为整个版本5都有错误。

npm i -g npm@4

我也尝试了最新的npm,但他们都没有工作。

当我在项目目录上运行npm install时,它没有安装/更新我的软件包,而是给出了以下错误

npm ERR! cb() never called!
npm ERR! This is an error with npm itself. Please report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

我看到所有依赖项都在node_modules中下载了

关于我错过的任何建议?

我还注意到,在创建应用程序时(使用create-react-native-app my-first-native-app),它还在控制台中添加了以下错误

yarn install v0.21.3
[1/4] Resolving packages...
warning jest-expo > jest > jest-cli > istanbul-api > [email protected]: 1.2.0 should have been a major version bump
[2/4] Fetching packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/react-native-web-maps/-/react-native-web-maps-
0.1.0.tgz: invalid tar file".
info If you think this is a bug, please open a bug report with the information provided in "C:\\reactJs-projects
\\MyNewNativeApp\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Failed to install

谢谢!

node.js reactjs react-native npm
3个回答
1
投票

重新安装你的NPM / YARN并获得最新版本的React Native我也有这个问题


1
投票

用你创建项目后

$ create-react-native-app my-first-native-app

在您输入项目文件夹后:

$ cd my-first-native-app

然后打开模拟器或连接到您的设备并运行

$ npm start

要么

$ react-native run-android

注意你已经安装了android-SDK和android-JDK并且你的模拟器正在运行


1
投票

在尝试了不同的版本之后,我最终使用了纱线并且它在第一个实例上工作。如果有人遇到类似的问题,那么我会建议使用Yarn并继续前进。创建应用程序后,可以切换回npm。这是非常常见的问题报告,对于许多开发人员来说,它适用于某些版本。

© www.soinside.com 2019 - 2024. All rights reserved.