visual-studio - 为什么我的 package.json 文件显示 react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz" 而不是 react-native 版本
问题描述
为什么我的 package.json 文件显示
反应原生:“https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz”
而不是像 react-native 版本
反应原生:0.60。
因此,我收到此错误:
错误:未安装 react-native。请运行
npm install
或yarn
在您的项目目录中。无法启动项目。请修复错误并重新启动项目。
实际上,我已经从 Codecanyon 购买了一个 react-native 应用程序,但开发人员并没有帮助我配置该应用程序。已经 4 天了,我无法构建应用程序。它有一个我已经上传的 php 后端并且运行良好,但是构建应用程序对我来说是一场噩梦。任何人都可以帮忙吗?
谢谢
编辑1:因此,在删除 node_modules 并再次执行 yarn install 后,应用程序出现此错误:fontFamily“AntDesign”不是系统字体,并且尚未通过 Font.loadAsync 加载。
如果您打算使用系统字体,请确保您输入了正确的名称并且您的设备操作系统支持该名称。
如果这是自定义字体,请务必使用 Font.loadAsync 加载它。
这是我的 package.json 文件
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject"
},
"dependencies": {
"@react-native-community/masked-view": "0.1.10",
"expo": "^38.0.0",
"expo-ads-admob": "~8.2.1",
"expo-facebook": "~8.2.1",
"expo-font": "~8.2.1",
"firebase": "7.9.0",
"moment": "^2.27.0",
"native-base": "^2.13.12",
"react": "16.11.0",
"react-dom": "16.11.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-38.0.2.tar.gz",
"react-native-carousel": "^0.12.0",
"react-native-device-detection": "^0.2.1",
"react-native-form-validator": "^0.3.2",
"react-native-gesture-handler": "~1.6.0",
"react-native-keyboard-aware-scroll-view": "^0.9.2",
"react-native-map-link": "^2.7.10",
"react-native-maps": "0.27.1",
"react-native-modalbox": "^2.0.0",
"react-native-reanimated": "~1.9.0",
"react-native-render-html": "^4.2.1",
"react-native-root-toast": "^3.2.1",
"react-native-safe-area-context": "~3.0.7",
"react-native-safe-area-view": "^1.1.1",
"react-native-screens": "~2.9.0",
"react-native-star-rating": "^1.1.0",
"react-native-super-grid": "^4.0.2",
"react-native-timeago": "^0.5.0",
"react-native-vector-icons": "^7.0.0",
"react-native-web": "~0.11.7",
"react-native-webview": "^10.3.2",
"react-navigation": "^4.4.0",
"react-navigation-drawer": "^2.5.0",
"react-navigation-stack": "^2.8.2",
"tcomb-form-native": "^0.6.20"
},
"devDependencies": {
"@babel/core": "^7.11.1",
"babel-preset-expo": "^8.2.3"
},
"private": true
}
应用程序.js:
从“反应”导入反应;
import { Asset } from 'expo-asset'; import * as Font from 'expo-font'; import { AppLoading } from 'expo'; import { Root } from "native-base"; import { StatusBar } from "react-native"; import AppPreLoader from "./application/components/AppPreLoader"; import firebaseConfig from './application/utils/Firebase'; import * as firebase from 'firebase'; firebase.initializeApp(firebaseConfig); import GuestNavigation from './application/navigations/Guest'; import LoggedNavigation from './application/navigations/Logged'; console.disableYellowBox = true; function cacheImages(images) { return images.map(image => { if (typeof image === 'string') { return Image.prefetch(image); } else { return Asset.fromModule(image).downloadAsync(); } }); } export default class App extends React.Component { constructor () { super(); this.state = { isLogged: false, loaded: false, isReady: false, } } async _loadAssetsAsync() { const imageAssets = cacheImages([ require('./assets/images/header.jpg'), require('./assets/images/logo.png'), require('./assets/images/logo_dark.png'), require('./assets/images/star.png'), require('./assets/images/avatar.png'), require('./assets/images/emptylist.png'), require('./assets/images/avatar.jpg'), require('./assets/images/nointernet.png'), require('./assets/images/contact.png'), require('./assets/images/address.png'), require('./assets/images/audience.png'), require('./assets/images/schedule.png'), require('./assets/images/phone.png'), require('./assets/images/website.png'), require('./assets/images/bookmarked.png'), require('./assets/images/checked.png'), ]); await Promise.all([...imageAssets]); } async componentDidMount () { await Expo.Font.loadAsync({ Roboto_medium: require("native-base/Fonts/Roboto_medium.ttf") }); await firebase.auth().onAuthStateChanged((user) => { if(user !== null) { this.setState({ isLogged: true, loaded: true }); } else { this.setState({ isLogged: false, loaded: true }); } }) } render() { if (!this.state.isReady) { return ( <AppLoading startAsync={this._loadAssetsAsync} onFinish={() => this.setState({ isReady: true })} onError={console.warn} /> ); } const {isLogged, loaded, isReady} = this.state; if ( ! loaded) { return ( <AppPreLoader/> ); } if(isLogged && isReady) { return ( <Root> <StatusBar barStyle="light-content" translucent={true} backgroundColor={'transparent'} /> <LoggedNavigation /> </Root> ); } else { return ( <Root> <StatusBar barStyle="dark-content" translucent={true} backgroundColor={'transparent'} /> <GuestNavigation /> </Root> ); } } }
edit2:在安装软件包时,我收到以下警告:
警告 expo > expo-constants > fbjs > core-js@2.6.11: core-js@<3 不再维护,由于问题数量不推荐使用。请将您的依赖项升级到 core-js@3 的实际版本。警告 expo > fbemitter > fbjs > core-js@1.2.7: core-js@<3 不再维护,由于问题数量不推荐使用。请将您的依赖项升级到 core-js@3 的实际版本。警告 react-native > fbjs-scripts > core-js@2.6.11: core-js@<3 不再维护,由于问题数量不推荐使用。请将您的依赖项升级到 core-js@3 的实际版本。警告反应本机
metro-babel-register > core-js@2.6.11: core-js@<3 不再维护,由于问题数量不推荐使用。请将您的依赖项升级到 core-js@3 的实际版本。警告 react-native > @react-native-community/cli > @hapi/joi@15.1.1: joi 将离开 @hapi 组织并回到 'joi' ( https://github.com/sideway/joi/问题/2411此版本已被弃用,不再支持或维护警告 react-native > @react-native-community/cli > metro-core > jest-haste-map > fsevents@1.2.13: fsevents 1 will break on node v14+ and可能正在使用不安全的二进制文件。升级到 fsevents 2. 警告 react-native > @react-native-community/cli > metro-core > jest-haste-map > micromatch snapdragon > source-map-resolve > resolve-url@0.2.1:https://github.com/lydell/resolve-url#deprecated警告 react-native @react-native-community/cli > metro-core > jest-haste-map > micromatch > snapdragon > source-map-resolve > urix@ 0.1.0:请参阅https://github.com/lydell/urix#deprecated警告 react-native-web > deep-assign@3.0.0:签出
lodash.merge
或merge-options
反而。[2/4] 获取包... info fsevents@1.2.13:平台“win32”与此模块不兼容。info "fsevents@1.2.13" 是一个可选的依赖项和失败的兼容性检查。从安装中排除它。[3/4] 链接依赖项...警告“native-base > eslint-config-prettier@6.11.0”未满足对等依赖项“eslint@>=3.14.1”。警告“native-base > @codler/react-native-keyboard-aware-scroll-view@1.0.0”具有不正确的对等依赖关系“react-native@>=0.63.0”。警告“ > react-native-carousel@0.12.0”具有未满足的对等依赖关系“create-react-class@>=15.6.2”。警告“ > react-native-maps@0.27.1”具有未满足的对等依赖性“prop-types@^15.0 || ^16.0”。警告“ > react-native-render-html@4.2。
解决方案
为什么你看到的是 GitHub URL 而不是 react-native 版本。
因为您使用的是 expo 而 expo 是一个基于 react-native 的库,所以您没有使用 react-native-cli
无法启动项目
按照以下步骤启动项目。
- 删除 node_modules 文件夹。
- 运行“纱线安装”。
- 运行“博览会开始”。
对于字体加载,看看这个。
推荐阅读
- javascript - 根据布尔对象道具生成字符串
- sql - 如何在 oracle 中使用批量收集来获取包含表的所有列的 Rowid
- c# - HashSet 包含和设置操作(例如除外)之间的不区分大小写有什么不同?
- python - Bigquery 的 GCP 云函数 JOIN 语句
- amazon-web-services - 多次 OOMKill 重启后的 AWS EKS + Fargate 错误
- sql - 将 SQL 中的前 N 个类别与“其他”中的所有其他类别相加
- c++ - 数独求解程序 - 输出没有变化
- typescript - 如何将此接口从 C# 转换为 TypeScript?
- vue.js - Vuex getter 在模块内部时没有反应
- axios - 是否可以在独立的 axios 服务文件中使用 $config 代替 process.env 访问 Nuxt runtimeConfig 值?