victorgarciaesgi / vue-chart-3

📊 A simple wrapper around Chart.js 3 for Vue 2 & 3

Home Page:https://vue-chart-3.netlify.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[ERR_REQUIRE_ESM]: require() of ES Module [...]/node_modules/vue-chart-3/dist/index.cjs not supported

fran6brg opened this issue · comments

Describe the bug

Hi,

Using https://github.com/antfu/vitesse, and running pnpm build

Error [ERR_REQUIRE_ESM]: require() of ES Module [...]/node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/lodash.js from [...]/node_modules/.pnpm/vue-chart-3@3.1.4_chart.js@3.7.1+vue@3.2.31/node_modules/vue-chart-3/dist/index.cjs not supported.
Instead change the require of lodash.js in [...]/node_modules/.pnpm/vue-chart-3@3.1.4_chart.js@3.7.1+vue@3.2.31/node_modules/vue-chart-3/dist/index.cjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> ([...]/node_modules/.pnpm/vue-chart-3@3.1.4_chart.js@3.7.1+vue@3.2.31/node_modules/vue-chart-3/dist/index.cjs:83:24)
    at Module.<anonymous> ([...]/.vite-ssg-temp/main.js:42:17)
    at build ([...]/node_modules/.pnpm/vite-ssg@0.15.6_ed701b91b90cc67e84b46b05038ae114/node_modules/vite-ssg/dist/node/cli.js:172:52)
    at async Object.handler ([...]/node_modules/.pnpm/vite-ssg@0.15.6_ed701b91b90cc67e84b46b05038ae114/node_modules/vite-ssg/dist/node/cli.js:283:3) {
  code: 'ERR_REQUIRE_ESM'
}
 ELIFECYCLE  Command failed with exit code 1.

Version of vue-chart-3

"vue-chart-3": "^3.1.4"

Version of Vue

  • Vue 3
  • Vue 2
  • Nuxt 2
  • Nuxt 3

Hi! That's weird because i use vitesse too internaly and it should take the esm build

commented

Had the same error in nuxt for vue 2, adding chart.js and vue-chart-3 to transpile fixed this error. Maybe it can fix your error too if you have a way to transpile.

I encountered this issue once again. Can't remember how I fixed it the first time.
However this (second) time it seems due to a mismatch between my tsconfig and the node version I was installing dependencies / building my app.

Anyway, I close this issue.