reactjs - 未找到模块:无法在 React 中解析“@date-io/date-fns”
问题描述
我正在使用 React Material UI 并收到此错误:找不到模块:无法解析“@date-io/date-fns”。
以下是我的 package.json 文件中的依赖项:
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.12.1",
"@material-ui/icons": "^4.11.2",
"@material-ui/pickers": "^3.3.10",
"@testing-library/jest-dom": "^5.11.8",
"@testing-library/react": "^11.2.2",
"@testing-library/user-event": "^12.6.0",
"antd": "^4.16.6",
"axios": "^0.21.1",
"bootstrap": "^4.5.3",
"query-string": "^4.3.4",
"react": "^17.0.1",
"react-bootstrap": "^1.4.0",
"react-dom": "^17.0.1",
"react-owl-carousel": "^2.3.3",
"react-router-dom": "^5.2.0",
"react-script-tag": "^1.1.2",
"react-scripts": "4.0.1",
"react-seat-picker": "^1.5.3",
"react-tooltip": "^4.2.21",
"web-vitals": "^0.2.4"
},
我尝试安装这些库,但它一直在命令提示符下显示错误
D:\WebSites\site>npm i --save date-fns@next @date-io/date-fns
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: site@0.1.0
npm ERR! Found: date-fns@2.0.0-beta.5
npm ERR! node_modules/date-fns
npm ERR! date-fns@"2.0.0-beta.5" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional date-fns@"^2.0.0" from @date-io/date-fns@2.11.0
npm ERR! node_modules/@date-io/date-fns
npm ERR! @date-io/date-fns@"*" 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\Ryan\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\Ryan\AppData\Local\npm-cache\_logs\2021-08-11T12_31_59_156Z-debug.log
解决方案
推荐阅读
- java - 在 IntelliJ 中使用 SimpleEmail 从命令行失败
- c++ - boost::asio::read_some 在没有轮询的情况下完成后从主线程读取完成时如何同步?
- javascript - RxJS 过滤/分组去抖动
- api - 是否可以根据提交的答案更新谷歌表单问题?
- javascript - 使用 JavaScript 循环浏览本地存储的 HTML 视频
- jsf - 为什么我的自定义 javax.faces.context.ExceptionHandler 不处理 javax.validation.ConstraintViolationException
- next.js - 如何在 Next.js 中从服务器获取 slug 到标头
- javascript - 条件练习 addWithSurcharge
- jquery - 使用 jquery 单击按钮时显示三个 div
- c# - 尝试将 linq 数据分配到 DTO 类时出错