我正在尝试通过运行来安装库@material-ui/pickers:
npm i @material-ui/pickers
但是出现这个错误:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: five@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! peer react@"^16.8.0 || ^17.0.0" from @material-ui/core@4.11.3
npm ERR! node_modules/@material-ui/core
npm ERR! @material-ui/core@"^4.11.3" from the root project
npm ERR! peer @material-ui/core@"^4.0.0" from @material-ui/pickers@3.2.10
npm ERR! node_modules/@material-ui/pickers
npm ERR! @material-ui/pickers@"*" from the root project
npm ERR! 1 more (react-dom)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.4" from @material-ui/pickers@3.2.10
npm ERR! node_modules/@material-ui/pickers
npm ERR! @material-ui/pickers@"*" 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 依赖项:
"dependencies": {
"@material-ui/core": "^4.11.3",
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.3",
"@testing-library/user-event": "^12.6.2",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.1",
"web-vitals": "^0.2.4"
},
我认为我的文件的其他部分可能有一些问题,所以我从头开始创建一个 create-react-app 并再次尝试,但同样的错误仍然发生。
答案 0 :(得分:1)
也许您想从 here 中查看新的 Material UI DatePicker。如果我理解正确@material-ui/pickers isn't used anymore。
答案 1 :(得分:0)
@material-ui/pickers
要求 react
为 16.13.1 或更高版本,但不要求为 17.xx.xx。现在你使用的是 React 17.0.1 版。您可以尝试将 React 降级到 16 版,看看是否有效
答案 2 :(得分:0)
我什至遇到了这个错误,我所做的只是关闭了我的 VScode,因为项目在其中打开,然后再次尝试安装包并猜测它的工作原理。你可以试试这个解决方案,希望它有效。