繁体   English   中英

在 ReactJs 中安装节点模块时出错

[英]Error while installing node module in ReactJs

我刚刚从 Git 克隆了一个没有node_modules的 React 应用程序。 我尝试使用命令npm install但无法执行。 安装npm时出现如下错误。

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: fuse-react-app@2.0.0
npm ERR! Found: date-fns@2.0.0-alpha.26
npm ERR! node_modules/date-fns
npm ERR!   date-fns@"2.0.0-alpha.26" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer date-fns@"2.0.0-alpha.21" from @date-io/date-fns@1.0.1
npm ERR! node_modules/@date-io/date-fns
npm ERR!   @date-io/date-fns@"1.0.1" 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\...\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\...\AppData\Local\npm-cache\_logs\2022-04-24T12_44_19_589Z-debug-0.log

我什至尝试过npm install --legacy-peer-deps但没有用。 我该如何解决这个问题?

长话短说

此问题的可能解决方案是将date-fns -fns 的版本设置为2.0.0-alpha.21


完整答案

要解决您的问题,您可以更改date-fns的版本。

为此,请按照下列步骤操作。

  1. package.json中,使用以下内容编辑date-fns fns 的版本:

     { "dependencies": { "date-fns": "2.0.0-alpha.21" } }
  2. 保存package.json文件,在与package.json相同的目录下运行以下命令。

     $ npm install
  3. 您的依赖项应该安装成功。


结论

总之,您需要将date-fns -fns 的版本更改为2.0.0-alpha.21

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM