【发布时间】:2020-11-28 20:51:54
【问题描述】:
为什么我的 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
}
App.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> ); } } }
编辑2: 此外,在安装软件包时,我会收到以下警告:
warning expo > expo-constants > fbjs > core-js@2.6.11: core-js@ fbemitter > fbjs > core-js@1.2.7: core-js@ fbjs-scripts > core-js@2.6.11: core-js@
metro-babel-register > core-js@2.6.11: core-js@ @react-native-community/cli > @hapi/joi@15.1.1: joi 将离开 @hapi 组织并回到 'joi' (https://github.com/sideway/joi/issues/2411) 警告 react-native > @react- native-community/cli > @hapi/joi > @hapi/address@2.1.4:此版本已被弃用,不再支持或维护警告 react-native > @react-native-community/cli > @hapi/joi > @hapi/bourne@1.3.2:此版本已被弃用,不再支持或维护警告 react-native > @react-native-community/cli > @hapi/joi > @hapi/hoek@8.5.1:此版本已被弃用,不再支持或维护警告 react-native > @react-native-community/cli > @hapi/joi > @hapi/topo@3.1.6:此版本已被弃用,不再受支持或维护警告 react-native > @react-native-community/cli > @hapi/joi > @hapi/topo > @hapi/hoek@8.5.1:此版本已被弃用,不再支持或维护警告 react-原生 > @react-native-community/ cli > metro-core > jest-haste-map > fsevents@1.2.13:fsevents 1 将在节点 v14+ 上中断,并且可能使用不安全的二进制文件。升级到 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.2”具有未满足的对等依赖性“prop-types@>=15.5.10”。
【问题讨论】:
-
你尝试运行 npm install 吗?
-
是的,使用纱线安装。如果您愿意,我可以与您共享应用程序文件。如果你能帮我解决这个问题,那就太好了。
-
我认为你应该用你得到的确切错误和关于 package.json 的更多细节来更新你的问题
-
自从您从 CodeCanyon 购买了该应用程序,他们有责任为您提供支持。否则我猜你可以选择退款。关于上述错误,似乎是该应用程序正在使用Expo。安装软件包后,您是否看到
node_modules文件夹中的文件夹?您在运行安装时是否看到任何错误(我猜可能粘贴该日志会有所帮助)。 -
不,Codecanyon 没有退款政策。无论如何,nnode_modules 对我来说看起来不错,但我在安装软件包时确实收到了警告。
标签: visual-studio react-native expo