【问题标题】:Cannot install react-paypal-button-v2无法安装 react-paypal-button-v2
【发布时间】:2022-04-03 00:43:00
【问题描述】:

我正在学习电子商务教程,但与讲师不同的是,我无法安装 react-paypal-button-v2

我的错误日志是

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: frontend@0.1.0
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR!   react@"^17.0.1" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^0.14.6 || 15.x.x || 16.x.x" from react-paypal-button-v2@2.6.2
npm ERR! node_modules/react-paypal-button-v2
npm ERR!   react-paypal-button-v2@"*" 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.

如果有帮助,这是我的 package.json 文件:

{
    "name": "frontend",
    "proxy": "http://localhost:8000",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
        "@testing-library/jest-dom": "^5.11.4",
        "@testing-library/react": "^11.1.0",
        "@testing-library/user-event": "^12.1.10",
        "axios": "^0.21.1",
        "dotenv": "^8.2.0",
        "moment": "^2.29.1",
        "react": "^17.0.1",
        "react-bootstrap": "^1.4.3",
        "react-dom": "^17.0.1",
        "react-redux": "^7.2.2",
        "react-router-bootstrap": "^0.25.0",
        "react-router-dom": "^5.2.0",
        "react-scripts": "4.0.1",
        "redux": "^4.0.5",
        "redux-devtools-extension": "^2.13.8",
        "redux-thunk": "^2.3.0",
        "web-vitals": "^0.2.4"
    },
    "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test",
        "eject": "react-scripts eject"
    },
    "eslintConfig": {
        "extends": [
            "react-app",
            "react-app/jest"
        ]
    },
    "browserslist": {
        "production": [
            ">0.2%",
            "not dead",
            "not op_mini all"
        ],
        "development": [
            "last 1 chrome version",
            "last 1 firefox version",
            "last 1 safari version"
        ]
    }
}

我很困惑,因为我的依赖树与讲师完全相同,唯一的区别是我安装了 momentdotenv,并且他在 PC 上运行而我在 Mac 上运行,但他安装它没有问题。

教程是最新的(不到一个月的时间),他的 package.json 中的版本与我的基本相同。

我发现此打开 issue,但开发人员尚未解决此问题。

我很想知道如何解决这个问题并继续进行下去,我相信这也将有助于我将来如何对这些错误进行排序。

谢谢!

【问题讨论】:

    标签: reactjs npm paypal dependencies


    【解决方案1】:

    这是 npm 的问题。你可以用 yarn 安装它,它会正常工作。

    yarn add react-paypal-button-v2
    

    纱线安装steps

    【讨论】:

    • 谢谢你。我在安装之前尝试过这个,安装程序提到有一个错误的依赖树。我还注意到包 (2.6.2) 的最新版本是从 2020 年 4 月开始的,并且它的 package.json 使用 React v 16.8.2 作为依赖项。到目前为止,我一直在使用 npm,想知道切换到 yarn 是否会导致未来出现问题,或者我是否需要再次对整个项目进行纱线化。
    【解决方案2】:

    npm install react-paypal-button-v2 --force

    使用 --force 它将起作用

    【讨论】:

      猜你喜欢
      • 2022-01-05
      • 2020-03-29
      • 1970-01-01
      • 2020-11-12
      • 2021-11-30
      • 2019-12-22
      • 1970-01-01
      • 1970-01-01
      • 2023-01-02
      相关资源
      最近更新 更多