安装 npm 包时出错(依赖树)

时间:2021-05-11 14:58:28

标签: reactjs npm

我正在尝试安装包 react-lottie https://www.npmjs.com/package/react-lottie

但是我遇到了这个错误,我想知道如何解决这个问题,我知道这与依赖有关,但我很难找到答案。

错误:

enter image description here

package.json

{
    "name": "laforga",
    "version": "1.0.0",
    "private": true,
    "description": "laforga",
    "keywords": [
        "gatsby"
    ],
    "scripts": {
        "develop": "gatsby develop",
        "start": "gatsby develop",
        "build": "gatsby build",
        "serve": "gatsby serve",
        "clean": "gatsby clean"
    },
    "dependencies": {
        "gatsby": "^3.4.1",
        "gatsby-image": "^3.4.0",
        "gatsby-plugin-google-analytics": "^3.4.0",
        "gatsby-plugin-offline": "^4.4.0",
        "gatsby-plugin-react-helmet": "^4.4.0",
        "gatsby-plugin-sass": "^4.4.0",
        "gatsby-plugin-sharp": "^3.4.2",
        "gatsby-remark-lottie": "^1.0.3",
        "gatsby-source-filesystem": "^3.4.0",
        "gatsby-transformer-sharp": "^3.4.0",
        "react": "^17.0.1",
        "react-dom": "^17.0.1",
        "react-helmet": "^6.1.0",
        "sass": "^1.32.12"
    }
}

1 个答案:

答案 0 :(得分:0)

看起来您使用的包需要 React v16,而您使用的是 v17。为了使其工作,您应该能够使用 npm install react@16 降级您的 React 版本。