微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我在“npm i ngx-slick-carousel”时遇到错误,角度为 11

如何解决我在“npm i ngx-slick-carousel”时遇到错误,角度为 11

我在执行“npm i ngx-slick-carousel --save”时出错

我的版本是:

$ npm -v
7.6.1

$ node -v
v14.17.0

Angular CLI: 11.2.13

错误是:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: irt-official@0.0.0
npm ERR! Found: @angular/common@11.2.14
npm ERR! node_modules/@angular/common
npm ERR!   @angular/common@"~11.2.13" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^7.0.0 || ^8.0.0 || ^9.0.0" from ngx-slick-carousel@0.5.1
npm ERR! node_modules/ngx-slick-carousel
npm ERR!   ngx-slick-carousel@"*" 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\malik\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\malik\AppData\Local\npm-cache\_logs\2021-05-19T14_13_57_035Z-debug.log

package.json:

"@angular/animations": "~11.2.13","@angular/common": "~11.2.13","@angular/compiler": "~11.2.13","@angular/core": "~11.2.13","@angular/forms": "~11.2.13","@angular/platform-browser": "~11.2.13","@angular/platform-browser-dynamic": "~11.2.13","@angular/router": "~11.2.13","angular-animations": "^0.11.0","jquery": "^3.6.0","rxjs": "~6.6.0","slick-carousel": "^1.8.1","tslib": "^2.0.0","zone.js": "~0.11.3"

请帮助我解决这个问题。为什么我无法安装这个。谢谢

更新 1:

我已删除 node_module 和 packagelock.json 文件并尝试执行“npm install”,但现在出现此错误

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: irt-official@0.0.0
npm ERR! Found: @angular/core@11.2.14
npm ERR! node_modules/@angular/core
npm ERR!   @angular/core@"~11.2.13" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/core@"12.0.1" from @angular/animations@12.0.1
npm ERR! node_modules/@angular/animations
npm ERR!   peer @angular/animations@">=6.0.0" from angular-animations@0.11.0
npm ERR!   node_modules/angular-animations
npm ERR!     angular-animations@"^0.11.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict,or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\malik\AppData\Local\npm-cache\eresolve-report.txt

获取完整报告。

更新 2:

我已经完成了“npm install --legacy-peer-deps”这个命令安装了我的 node_module 但是当我在安装后执行“ng serve”时出现这个错误

发生未处理的异常:目标入口点“@angular/platform-b​​rowser/animations”缺少依赖项:

  • @angular/动画
  • @angular/animations/browser

更新 3:

我已经完全刷新了所有东西,就像我卸载了 node 和 angular cli 并重新安装了

节点版本 16.2.0

npm -v: 7.6.1

Angular CLI:12.0.1

现在我创建了新项目“ng new IRT-Official” 然后我再次尝试执行“npm install ngx-slick-carousel --save” 现在我收到此错误

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: irt-official@0.0.0
npm ERR! Found: @angular/common@12.0.1
npm ERR! node_modules/@angular/common
npm ERR!   @angular/common@"~12.0.1" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/common@"^7.0.0 || ^8.0.0 || ^9.0.0" from ngx-slick-carousel@0.5.1
npm ERR! node_modules/ngx-slick-carousel
npm ERR!   ngx-slick-carousel@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict,or --legacy-peer-deps
npm ERR! to 

更新 4:

我在我的 packege.json 文件中手动添加了“ngx-slick-carousel”:“0.5.1”,然后“npm install --legacy-peer-deps”它安装了 crousal 但是当我完成所有步骤时我出现错误

未捕获的类型错误:$(...).owlCarousel 不是函数

解决方法

更新

您似乎没有运行 https://www.npmjs.com/package/ngx-slick-carousel

中的安装步骤

enter image description here

上一个

您 package.json 正在寻找 "@angular/common": "~11.2.13" 但是您已经安装了 11.2.14 版

将您的 package.json 更新为

   "@angular/common": "^11.2.13"

   "@angular/common": "^11.2.14"

What's the difference between tilde(~) and caret(^) in package.json?

,

您可以通过在您的节点模块中编辑找到光滑的轮播文件夹并转到包模块,在那里您可以找到版本历史记录来解决此问题-您需要在看到版本 9 的任何地方进行更新并添加 10 和 11 . 问题是,在将其投入生产之前,您还必须针对多段代码进行安全测试和单元测试 - 或者无论如何应该这样做,您可能应该找到一个保持最新的轮播模块。

任何您看到@angular 的地方都将其更改为下方

"^7.0.0 || ^8.0.0 || ^9.0.0 || ^10.0.0 || ^11.0.0"

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。