ERR_REQUIRE_ESM #78

Closed
opened 2023-02-12 16:56:20 +08:00 by chaodosen · 3 comments
chaodosen commented 2023-02-12 16:56:20 +08:00 (Migrated from github.com)

ce92688a88/package.json (L21)

作者你好!
@antv/g2plot 这个依赖引入之后,本地启动控制台无报错,可以正常显示标签云,但是打包会报错,报错信息如下:

Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\coderzds\Desktop\mercury\docs\node_modules.pnpm\registry.npmmirror.com+d3-interpolate@3.0.1\node_modules\d3-interpolate\src\index.js from C:\Users\coderzds\Desktop\mercury\docs\node_modules.pnpm\registry.npmmirror.com+@antv+g-base@0.5.14\node_modules@antv\g-base\lib\animate\timeline.js not supported.

我在其他地方找到类似的错误:
https://github.com/ant-design/ant-design/issues/40644

请问这个有解决办法么

https://github.com/Charles7c/charles7c.github.io/blob/ce92688a88e20ffa868b5b08d27910e4244729b7/package.json#L21 作者你好! @antv/g2plot 这个依赖引入之后,本地启动控制台无报错,可以正常显示标签云,但是打包会报错,报错信息如下: Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Users\coderzds\Desktop\mercury\docs\node_modules\.pnpm\registry.npmmirror.com+d3-interpolate@3.0.1\node_modules\d3-interpolate\src\index.js from C:\Users\coderzds\Desktop\mercury\docs\node_modules\.pnpm\registry.npmmirror.com+@antv+g-base@0.5.14\node_modules\@antv\g-base\lib\animate\timeline.js not supported. 我在其他地方找到类似的错误: https://github.com/ant-design/ant-design/issues/40644 请问这个有解决办法么
Charles7c commented 2023-02-13 10:51:21 +08:00 (Migrated from github.com)

你好,刚看到你的消息,回复的稍晚了些,抱歉。

我刚才依次确认了下:

  1. 我们当前使用的 @antv/g2plot 版本都是 "@antv/g2plot": "^2.4.23"
  2. 我本地运行及打包测试正常;
    image
  3. 我查看了下 @antv/g2plot 的最新版本,最新版是 v2.4.25;
    image
  4. 我尝试升级依赖版本,并继续运行及打包测试;
    image
    然后打包时也出现了相同的错误,可以初步确定这是由于 @antv/g2plot 版本升级导致的问题。
    image
    因为在版本号前用了 ^ 符号,所以它会自动更新版本到当前相同大版本的最新版本,例如:v2.4.23 => v2.4.25 会自动升级,但 v2.4.23 => v3.x.x 不会自动升级。
  5. 针对这个问题的解决方法,目前有两个:
    a) 将 @antv/g2plot 版本锁定,即修改 package.json,将 "@antv/g2plot": "^2.4.23" 改为 "@antv/g2plot": "2.4.23",我已经再次运行及打包测试过了,没有问题。
    image
    b) 关注相关库的 issues,需要调研解决。
  6. 实际上,我们的知识库仅是用到了 “WordCloud(词云)” 组件,且目前功能可以满足需要,所以可以直接采用第1种解决方法,第2种方法容我空闲时间调研确认一下,最近比较忙。
你好,刚看到你的消息,回复的稍晚了些,抱歉。 我刚才依次确认了下: 1. 我们当前使用的 @antv/g2plot 版本都是 `"@antv/g2plot": "^2.4.23"`; 2. 我本地运行及打包测试正常; ![image](https://user-images.githubusercontent.com/25446948/218356493-2e34b00b-a552-49be-b48d-fefecb31b31b.png) 3. 我查看了下 @antv/g2plot 的最新版本,最新版是 v2.4.25; ![image](https://user-images.githubusercontent.com/25446948/218356692-cb747ad1-9522-48f2-9f66-a45661a7d4a9.png) 4. 我尝试升级依赖版本,并继续运行及打包测试; ![image](https://user-images.githubusercontent.com/25446948/218357288-eacec746-1106-487f-b0f4-bd3eed17c74d.png) 然后打包时也出现了相同的错误,可以初步确定这是由于 @antv/g2plot 版本升级导致的问题。 ![image](https://user-images.githubusercontent.com/25446948/218357609-fadc7b4d-bd7a-46e9-82ae-10dc0f4d18a6.png) 因为在版本号前用了 ^ 符号,所以它会自动更新版本到当前相同大版本的最新版本,例如:v2.4.23 => v2.4.25 会自动升级,但 v2.4.23 => v3.x.x 不会自动升级。 5. 针对这个问题的解决方法,目前有两个: a) **将 @antv/g2plot 版本锁定,即修改 package.json,将 `"@antv/g2plot": "^2.4.23"` 改为 `"@antv/g2plot": "2.4.23"`**,我已经再次运行及打包测试过了,没有问题。 ![image](https://user-images.githubusercontent.com/25446948/218359167-25135bac-ca93-481a-9035-4873666150f8.png) b) 关注相关库的 issues,需要调研解决。 6. 实际上,我们的知识库仅是用到了 “WordCloud(词云)” 组件,且目前功能可以满足需要,所以可以直接采用第1种解决方法,第2种方法容我空闲时间调研确认一下,最近比较忙。
chaodosen commented 2023-02-13 17:19:23 +08:00 (Migrated from github.com)

感谢帮助

抱歉回复这么晚。

  1. 固定版本号之后还是同样的错误,我尝试降了很多版本都不行。
  2. 我也尝试换了很多node版本,依旧没有解决,作者用的是哪个版本呢?
  3. 直接拉你的项目是可以的。
  4. 我自己再研究一下吧,我学的比较菜。
  5. 如果作者有时间可以看下我的demo:https://github.com/chaodosen/docs
> 感谢帮助 **抱歉回复这么晚。** 1. 固定版本号之后还是同样的错误,我尝试降了很多版本都不行。 2. 我也尝试换了很多node版本,依旧没有解决,作者用的是哪个版本呢? 3. 直接拉你的项目是可以的。 4. 我自己再研究一下吧,我学的比较菜。 5. 如果作者有时间可以看下我的demo:https://github.com/chaodosen/docs
Charles7c commented 2023-02-25 18:40:24 +08:00 (Migrated from github.com)

@chaodosen
参照 https://github.com/ant-design/ant-design/issues/40644#issuecomment-1423628363 的解决方法,报错的直接原因是 @antv/g-base、@antv/path-util ,它们两个版本降低一下就没事了。
a0358e1079/package.json (L34-L38)

@chaodosen 参照 https://github.com/ant-design/ant-design/issues/40644#issuecomment-1423628363 的解决方法,报错的直接原因是 @antv/g-base、@antv/path-util ,它们两个版本降低一下就没事了。 https://github.com/Charles7c/charles7c.github.io/blob/a0358e1079c8fb9319a44bbfb20fd5e03f539bf8/package.json#L34-L38
This repo is archived. You cannot comment on issues.
No Label
1 Participants
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Charles7c/vitepress-theme-blog-charles7c-s1#78
No description provided.