Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dumi 中 @ant-design/icons-svg/package.json 依赖包找不到 React 版本警告 #1904

Open
212063551 opened this issue Sep 17, 2023 · 5 comments
Labels
question Further information is requested

Comments

@212063551
Copy link

我创建使用了dumi 创建了项目但是在安装完依赖以后,我在控制台得到了找不到 React 版本警告

具体报错信息:
No required version specified and unable to automatically determine one. Unable to find required version for "react" in description file (/node_modules/@ant-design/icons-svg/package.json). It need to be in dependencies, devDependencies or peerDependencies.

环境:

node 版本:v16.20.1

芯片:m1

dumi版本:"dumi": "^2.2.0" 和 "dumi": "^2.2.10" 均发现此问题

我单独测试l @ant-design/icons-svg 包 并未发现警告

下附测试环境:

测试 @ant-design/icons-svg在 npx create-react-app my-app 创建的项目中正常渲染
测试react 版本:"^18.2.0"

解决方案:
在 node_modules 里向 @ant-design/icons-svg/package.json 字段中添加具体的 React版本号,同时在项目的package.json 里也添加
React版本号。二者缺一不可。

@212063551 212063551 added the question Further information is requested label Sep 17, 2023
@Wxh16144
Copy link
Member

在 node_modules 里向 @ant-design/icons-svg/package.json 字段中添加具体的 React版本号,

@ant-design/icons-svg 这个包好像就不需要 react 吧?

@212063551
Copy link
Author

在node_modules里向@ant-design/icons-svg/package.json字段中添加具体的React版本号,

@ant-design/icons-svg这个包需要react吧?

是的,我也认为不需要react ,但是这个报错信息确实是缺少react 。

使用操作 npx create-dumi 创建项目后选择 Static Site 后运行项目控制台就警告找不到react

报错行 :client.js:169

报错信息 :No required version specified and unable to automatically determine one. Unable to find required version for "react" in description file (/node_modules/@ant-design/icons-svg/package.json). It need to be in dependencies, devDependencies or peerDependencies.

@PeachScript
Copy link
Member

报错堆栈贴一下?

@212063551
Copy link
Author

212063551 commented Sep 18, 2023

截屏2023-09-18 09 54 53 > 报错堆栈贴一下? 以下是详细图片 截屏2023-09-18 09 37 07 截屏2023-09-18 09 36 49 截屏2023-09-18 09 37 30

@Wxh16144
Copy link
Member

Wxh16144 commented Oct 9, 2023

应该是 dumi 上游 umijs 用了 Webpack Module Federation 的特性导致的。查阅了几个相关的 issue, 貌似没找到解决方案,一个最简单粗暴的方法就是在 .dumirc 中添加 mfsu: false 来禁用模块联邦 😂

ref:

Wxh16144 added a commit to Wxh16144/dumi-debug-app that referenced this issue Oct 9, 2023
Wxh16144 added a commit to Wxh16144/dumi-debug-app that referenced this issue Oct 9, 2023
* chore: 验证依赖缺失警告

ref: umijs/dumi#1904 (comment)

* chore: update lock file

* chore: update site
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants