react-native - 导入 Lottie 时出现“解决时:未定义@未定义”错误
问题描述
我正在尝试导入 Lottie 以响应本机和博览会,我绝对是这方面的初学者。我安装了这个版本的 react-native:4.14.0
我不明白“解决时:undefined@undefined 是什么意思?但我想我的版本有冲突。
$ npm i --save lottie-react-native
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: undefined@undefined
npm ERR! Found: react@16.8.3
npm ERR! node_modules/react
npm ERR! react@"16.8.3" from the root project
npm ERR! peer react@"*" from lottie-react-native@3.5.0
npm ERR! node_modules/lottie-react-native
npm ERR! lottie-react-native@"*" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"16.9.0" from react-native@0.61.5
npm ERR! node_modules/react-native
npm ERR! react-native@"^0.61.4" from the root project
npm ERR! peer react-native@">=0.46" from lottie-react-native@3.5.0
npm ERR! node_modules/lottie-react-native
npm ERR! lottie-react-native@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\carol\AppData\Local\npm-cache\eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\carol\AppData\Local\npm-cache\_logs\2021-04-06T18_50_38_327Z-debug.log
//DEPENDENCIES from package.json:
"dependencies": {
"@react-native-community/cli-hermes": "^4.13.0",
"@react-native-community/cli-server-api": "^5.0.1-alpha.2",
"anser": "^2.0.1",
"braces": "^3.0.2",
"error-stack-parser": "^2.0.6",
"expo": "^40.0.1",
"expo-sensors": "^9.2.0",
"mem": "^8.1.0",
"minimist": "^1.2.5",
"node-stream-zip": "^1.13.3",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-native": "^0.64.0",
"react-native-google-fonts": "^0.0.0",
"react-native-web": "^0.15.5",
"styled-components": "^5.2.3",
"use-subscription": "^1.5.1"
}
解决方案
在 Expo 环境中,您必须通过以下方式安装 Lottie :
expo install lottie-react-native
如果尚未完成,请删除 lottie-react-native 的条目并通过 expo 安装它。它应该像这样工作。
您可以将以下 Package.json 条目替换为:
“反应”:“16.13.1”,
“反应域”:“16.13.1”,
"react-native": "https://github.com/expo/react-native/archive/sdk-40.0.0.tar.gz",
我认为 React 版本与 Expo React Native 版本不兼容。
推荐阅读
- datatables - 更新表时运行 DataTables 的 ajax() 函数
- html - 如何使用 jquery 设置 div 的位置?
- java - Android 用户登录与改造
- redirect - 如何使用 .Htaccess 将移动版本重定向到计算机版本
- javascript - 试图在 TypeScript 中找到 if/else 语句的动态替代方案
- python - 数据基数是 Keras 中的模棱两可的错误
- function - 识别给定包/文件中的函数
- git - VS 代码源控制充满垃圾文件
- scala - 如何将单片眼镜库添加到我的 scala 项目中?
- python - 当尝试提取偶数值时,我不断收到 typeError: 'int' object is not iterable whn tryoing