React-currency-format 未安装,如何修复?

ham*_*iam 5 npm reactjs npm-install

我试图在我的项目中使用react-currency-format 库,但无法安装该包。我认为依赖项有问题,但我无法弄清楚什么与什么相冲突。

# npm resolution error report

2021-02-20T09:51:09.030Z

While resolving: x-clone@0.1.0
Found: react@17.0.1
node_modules/react
  react@"^17.0.1" from the root project

Could not resolve dependency:
peer react@"^0.14 || ^15.0.0-rc || ^15.0.0 || ^16.0.0-rc || ^16.0.0" from react-currency-format@1.0.0
node_modules/react-currency-format
  react-currency-format@"*" from the root project

Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.

Raw JSON explanation object:

{
  "code": "ERESOLVE",
  "current": {
    "name": "react",
    "version": "17.0.1",
    "whileInstalling": {
      "name": "x-clone",
      "version": "0.1.0",
      "path": "/Users/Hamed_Iam/Desktop/x-clone"
    },
    "location": "node_modules/react",
    "dependents": [
      {
        "type": "prod",
        "name": "react",
        "spec": "^17.0.1",
        "from": {
          "location": "/Users/Hamed_Iam/Desktop/x-clone"
        }
      }
    ]
  },
  "edge": {
    "type": "peer",
    "name": "react",
    "spec": "^0.14 || ^15.0.0-rc || ^15.0.0 || ^16.0.0-rc || ^16.0.0",
    "error": "INVALID",
    "from": {
      "name": "react-currency-format",
      "version": "1.0.0",
      "whileInstalling": {
        "name": "x-clone",
        "version": "0.1.0",
        "path": "/Users/Hamed_Iam/Desktop/x-clone"
      },
      "location": "node_modules/react-currency-format",
      "dependents": [
        {
          "type": "prod",
          "name": "react-currency-format",
          "spec": "*",
          "from": {
            "location": "/Users/Hamed_Iam/Desktop/x-clone"
          }
        }
      ]
    }
  },
  "peerConflict": null,
  "strictPeerDeps": false,
  "force": false
}

Run Code Online (Sandbox Code Playgroud)

我也尝试过npm install react-currency-format --save,但没有成功。我的 npm 版本是 7.5.3 和 Node v14.15.4,我不想使用--force. 有解决方法吗?

小智 7

像这样使用 --force : npm install react-currency-format --save --force