ionic2-calendar 错误:找不到模块:从 Swiper 包中未导出 Angular。

huangapple go评论66阅读模式
英文:

ionic2-calendar Error: Module not Found: Angular is not exported from package Swiper

问题

我更新了我的项目的包

  • Ionic + Angular 以生成适用于 IOS 和 Android 的应用程序
  • Ionic: 7
  • Angular: 16

自从这个建议以来

> ion-slides 在 v6.0.0 中已弃用,并在 v7.0.0 中移除。我们建议直接使用 Swiper.js 库。

我迁移到了最新版本的 swiper(版本=9.3.2)

但是在更新了 package.json 并运行 ionic build 后,我遇到了这个问题

./node_modules/ionic2-calendar/fesm2020/ionic2-calendar.mjs:8:0-37 - 错误: 未找到模块: 错误: 未从包 /Users/admin/Projects/<name_project>/node_modules/swiper 中导出包路径 ./angular(请参阅 /Users/admin/Projects/<name_project>/node_modules/swiper/package.json 中的 exports 字段)

我查看了 node_modules/swiper,但我没有找到与 Angular 相关的路径
并且检查了 ionic2-calendar 的代码,我看到它们尝试导入 swiper/angular

import * as i3 from 'swiper/angular';
import { SwiperModule } from 'swiper/angular';

根据这个 答案 看来,Swiper 版本 9 不支持 Angular,我们需要迁移到在 Angular 中使用 Swiper 的新方式。我在我的代码中做了这个,但在第三方代码中,比如 ionic2-calendar,我没有这样做

在这种情况下,建议是什么?我应该降级到版本 9 并使用版本 8 吗?

英文:

I updated the package of my project

  • Ionic + angular to generate app for IOS and Android
  • Ionic: 7
  • Angular: 16

Since this recommendation

> ion-slides was deprecated in v6.0.0 and removed in v7.0.0. We
> recommend using the Swiper.js library directly.

I migrated to the last version of swiper(version= 9.3.2)

But after update package.json and run ionic build I got this issue

./node_modules/ionic2-calendar/fesm2020/ionic2-calendar.mjs:8:0-37 - Error: Module not 
found: Error: Package path ./angular is not exported from package 
/Users/admin/Projects/&lt;name_project&gt;/node_modules/swiper (see exports field in 
/Users/admin/Projects/&lt;name_project&gt;/node_modules/swiper/package.json)

I reviewed node_modules/swiper and I did't find a path to angular
And checking the code of ionic2-calendar I see that they try import swiper/angular

import * as i3 from &#39;swiper/angular&#39;;
import { SwiperModule } from &#39;swiper/angular&#39;

Checking this answer it looks like Swiper Version 9 doesn't have support to Angular and we need to migrate to the new way to use swiper in angular. I did that in my code but in the third part code like ionic2-calendar I didn't do that

What is the recommendation in this case? Should I downgraded the version 9 and use the version 8?

答案1

得分: 1

我将为您翻译以下部分:

"I downgraded Swiper from version 9 to Version 8.4.7 that works for me"

我将Swiper从版本9降级到版本8.4.7,这对我有效。

"The last version of ionic2-calendar was updated 4 months ago, almost the same date of the update of Swiper to version 9, so probably to use the last version of Swiper we need to wait for a new update of ionic2-calendar"

ionic2-calendar的最新版本是4个月前更新的,几乎与Swiper升级到版本9的日期相同,所以可能要使用Swiper的最新版本,我们需要等待ionic2-calendar的新更新。

ionic2-calendar 错误:找不到模块:从 Swiper 包中未导出 Angular。

英文:

I downgraded Swiper from version 9 to Version 8.4.7 that works for me

The last version of ionic2-calendar was updated 4 month ago almost the same Date of the update of Swiper to version 9, so probably to use the last version of Swiper we nee to wait for a new update ionic2-calendar
ionic2-calendar 错误:找不到模块:从 Swiper 包中未导出 Angular。

huangapple
  • 本文由 发表于 2023年5月28日 01:52:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76348281.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定