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

Server-side rendering error #3983

Closed
1 task
langhuihui opened this issue Apr 23, 2021 · 5 comments
Closed
1 task

Server-side rendering error #3983

langhuihui opened this issue Apr 23, 2021 · 5 comments
Labels

Comments

@langhuihui
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

2.1.1

Environment

vue 3.0.11

Reproduction link

https://github.com/langhuihui/test-ssr

Steps to reproduce

yarn
yarn build
yarn ssr

What is expected?

无报错

What is actually happening?

internal/modules/cjs/loader.js:1015
throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /……/node_modules/lodash-es/isPlainObject.js
require() of ES modules is not supported.
require() of /……/node_modules/lodash-es/isPlainObject.js from /……/node_modules/ant-design-vue/lib/_util/props-util/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename isPlainObject.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /……/node_modules/lodash-es/package.json.

at Object.Module._extensions..js (internal/modules/cjs/loader.js:1015:13)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object. (/……/node_modules/ant-design-vue/lib/_util/props-util/index.js:27:45)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14) {
code: 'ERR_REQUIRE_ESM'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@github-actions github-actions bot changed the title 服务端渲染报错 Server-side rendering error Apr 23, 2021
@zhuchentong
Copy link

我也遇到了一样的问题,使用vite ssr的官方demo 只要引入ant-design-vue就会报错,希望可以查看一下该问题
https://github.com/vitejs/vite/tree/main/packages/playground/ssr-vue

@NoeyNoi
Copy link

NoeyNoi commented Apr 28, 2021

+1

@hzm18
Copy link

hzm18 commented May 1, 2021

2.13 +1

@langhuihui
Copy link
Author

临时解决方案:在项目的node_module/ant-design-vue/lib下执行下面的替换
@ant-design/icons-vue => @ant-design/icons-vue/lib/icons
lodash-es => lodash/fp

tangjinzhou added a commit that referenced this issue May 12, 2021
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants