Closed AlexeyGlaznev closed 1 year ago
Each time when I run 'next build' command I get this error: Collecting page data ..Error [ERR_REQUIRE_ESM]: require() of ES Module node_modules/d3-geo/src/index.js from node_modules/react-svg-worldmap/dist/index.js not supported. Instead change the require of node_modules/d3-geo/src/index.js in node_modules/react-svg-worldmap/dist/index.js to a dynamic import() which is available in all CommonJS modules. This error exists in any Next js application, without any other dependencies except of default next js dependencies
Steps to reproduce the behavior:
- npx create-next-app@latest
- npm i react-svg-worldmap
- In any file write this: import WorldMap from 'react-svg-worldmap' console.log(WorldMap)
- npm run build
Expected behavior Building without problems
Desktop (please complete the following information):
- OS: MacOS 12.1
- Browser Chrome
The strange thing is that 'npm run dev' doesn't give any errors and you can use the package without any problems in the dev mode.
I am experiencing the same problem.
I am experiencing the same issue on my next js app. Package won't build.
Instead change the require of .../node_modules/d3-geo/src/index.js in .../node_modules/react-svg-worldmap/dist/index.js to a dynamic import() which is available in all CommonJS modules.
If you need an OSS app to repro this with, feel free to use https://github.com/flathub/website/pull/550
Sorry, I have very limited availability to debug this. My hypothesis is that Next.js' Webpack config doesn't transpile modules in node_modules by default, and we now emit ESM format. Is it possible to modify the Next.js webpack config?
Sorry everyone, I have been away doing my Masters and working full time. I am going to get back to this starting tomorrow. Thanks for your patience. -Yams
Hey @razzeee , @dbaileydev , @nathanhfoster , and @AlexeyGlaznev . The above error should be resolved in the latest version of the map on npm that I just posted. Can any of y'all check and close this issue? I was able to create a next.js app with the steps above with no compile issues. The issue was with the d3-geo and esm. Thanks, Yams
Seems to build fine now https://github.com/flathub/website/pull/1313/files
In that case I will close this issue, thanks for the quick reply @razzeee!
Fixed by #144
Each time when I run 'next build' command I get this error: Collecting page data ..Error [ERR_REQUIRE_ESM]: require() of ES Module node_modules/d3-geo/src/index.js from node_modules/react-svg-worldmap/dist/index.js not supported. Instead change the require of node_modules/d3-geo/src/index.js in node_modules/react-svg-worldmap/dist/index.js to a dynamic import() which is available in all CommonJS modules. This error exists in any Next js application, without any other dependencies except of default next js dependencies
Steps to reproduce the behavior:
Expected behavior Building without problems
Desktop (please complete the following information):
The strange thing is that 'npm run dev' doesn't give any errors and you can use the package without any problems in the dev mode.