【问题标题】:Getting "While resolving: undefined@undefined" error when importing Lottie导入 Lottie 时出现“解决时:未定义@未定义”错误
【发布时间】:2021-04-06 19:01:00
【问题描述】:

我正在尝试导入 Lottie 以用于 react native 和 expo,我绝对是这方面的初学者。我安装了这个版本的 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"
  }

【问题讨论】:

    标签: react-native expo lottie


    【解决方案1】:

    在 Expo 环境中你必须以不同的方式安装 Lottie via:

    expo install lottie-react-native
    

    如果尚未完成,请删除 lottie-react-native 的条目并通过 expo 安装它。它应该像这样工作。

    您能否将以下 Package.json 条目替换为:

    “反应”:“16.13.1”,

    "react-dom": "16.13.1",

    “react-native”:“https://github.com/expo/react-native/archive/sdk-40.0.0.tar.gz”,

    我认为 React 版本与 Expo React Native 版本不兼容。

    【讨论】:

    • 感谢您的回答。我卸载了 lottie-react-native 并尝试通过 expo install lottie-react-native 安装。但我仍然得到相同的答案“无法解析依赖树”等,下面是红色:npm exited with non-zero code: 1
    • @Caroline 我已经编辑了我的答案。您能否按照我在上面的回答中看到的那样修改 package.json?
    • 我按照建议做了,并将 react 和 react-dom 降级到 16.13.1,但仍然存在很多问题。我将在 React 项目中尝试 Lottie,但不会在这个 React-native 项目中。
    猜你喜欢
    • 2015-01-16
    • 1970-01-01
    • 2012-10-13
    • 1970-01-01
    • 1970-01-01
    • 2016-11-26
    • 2020-11-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多