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

@ant-design/pro-utils version 2.16.0 causing node ssr to fail #8627

Open
veeramarni opened this issue Aug 5, 2024 · 3 comments
Open

@ant-design/pro-utils version 2.16.0 causing node ssr to fail #8627

veeramarni opened this issue Aug 5, 2024 · 3 comments

Comments

@veeramarni
Copy link

提问前先看看:

https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/main/README-zh_CN.md

🔩 所属模块或组件

Nodejs pure esm fails

Failed to start server: Error [ERR_REQUIRE_ESM]: require() of ES Module /home/app/node_modules/lodash-es/lodash.js from /home/app/node_modules/@ant-design/pro-utils/lib/transformKeySubmitValue/index.js not supported.
Instead change the require of lodash.js in /home/app/node_modules/@ant-design/pro-utils/lib/transformKeySubmitValue/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/app/node_modules/@ant-design/pro-utils/lib/transformKeySubmitValue/index.js:12:17)
    at Object.<anonymous> (/home/app/node_modules/@ant-design/pro-utils/lib/index.js:480:32)
    at Object.<anonymous> (/home/app/node_modules/@ant-design/pro-layout/lib/components/SiderMenu/BaseMenu.js:17:17)
    at async startServer (file:///home/app/server.js:21:37) {
  code: 'ERR_REQUIRE_ESM'
}
/home/app/node_modules/@ant-design/pro-utils/lib/transformKeySubmitValue/index.js:12
var _lodashEs = require("lodash-es");
                ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/app/node_modules/lodash-es/lodash.js from /home/app/node_modules/@ant-design/pro-utils/lib/transformKeySubmitValue/index.js not supported.
Instead change the require of lodash.js in /home/app/node_modules/@ant-design/pro-utils/lib/transformKeySubmitValue/index.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/app/node_modules/@ant-design/pro-utils/lib/transformKeySubmitValue/index.js:12:17)
    at Object.<anonymous> (/home/app/node_modules/@ant-design/pro-utils/lib/index.js:480:32)
    at Object.<anonymous> (/home/app/node_modules/@ant-design/pro-layout/lib/components/SiderMenu/BaseMenu.js:17:17)
    at async startServer (file:///home/app/server.js:21:37) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v18.20.4


Could be related to this https://github.com/ant-design/pro-components/commit/9dffa8f7a467475a308bd9c68a6a0632bf300177#diff-c407fc35e4cbdcbe6777dfcb328fdfc7cea2f2e379ff59cfc4270231e6cecfd9R16
@Soumako
Copy link

Soumako commented Aug 13, 2024

I encounter this problem too. any solutions? nodejs version: 16.17.1

@navid-kalaei
Copy link

The cause of the error is this commit 455b4f1. rollback to a version before that which is 7.19.11

here is the commands:

yarn remove @ant-design/pro-layout
yarn add  @ant-design/pro-layout@7.19.11

References:

#8606
455b4f1

@veeramarni
Copy link
Author

veeramarni commented Sep 7, 2024

@sushi-su 455b4f1

这不是纯 esm,如果您在 cjs 文件中使用“lodash-es”,它会在 SSR 期间产生错误,因为 Node 不喜欢将 esm 与 cjs 混合。您可以通过生成与 cjs 并行的 .mjs 文件来获得与纯 esm 完全兼容的包。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants