element-plus / element-plus-nuxt-starter

🌰 A starter example for element-plus with Nuxt 3.
https://element-plus-nuxt.vercel.app
MIT License
289 stars 82 forks source link

Uncaught Error: Dynamic require of "@vueuse/core" is not supported #17

Closed darknoll closed 2 years ago

darknoll commented 2 years ago

Uncaught Error: Dynamic require of "@vueuse/core" is not supported at chunk-EABY2BFN.js:26 at node_modules/element-plus/lib/hooks/use-modal/index.js (element-plus_lib.js:7476) at require2 (chunk-EABY2BFN.js:32) at node_modules/element-plus/lib/hooks/index.js (element-plus_lib.js:10983) at require2 (chunk-EABY2BFN.js:32) at node_modules/element-plus/lib/make-installer.js (element-plus_lib.js:11039) at require2 (chunk-EABY2BFN.js:32) at node_modules/element-plus/lib/defaults.js (element-plus_lib.js:65543) at require2 (chunk-EABY2BFN.js:32) at node_modules/element-plus/lib/index.js (element-plus_lib.js:65921)

hzm18 commented 2 years ago

同样遇到这种情况。 node:17.2.0 npm:7.18.1 OS:Windows 10 64Bit

oooplz commented 2 years ago

Pleaseeeeeeeee help me! Its mostly disaster for me. I had been remove the package.json dependencies step on step, but i can not fixing that.

oooplz commented 2 years ago

Trying to use umd format import that packaged file. @hzm18 @darknoll

import ElementPlus from 'element-plus/dist/index.full';
import { defineNuxtPlugin } from '#app';

export default defineNuxtPlugin(nuxtApp => {
  nuxtApp.vueApp.use(ElementPlus);
});

@YunYouJun maybe have a solution elegant more than here.

my two cents:

When we use nuxt, we should be providing two build format, the one be in order to be used by ssr -- its commonJs format. other one be in order to be used by browser -- its esm format.

We can not to use import element-plus/lib and import element-plus to import element-plus, so that we should be using lement-plus/dist/index.full -- its is compatible with commonJs and esm.

polly3d commented 2 years ago

You save my life. But the button style is still not working. No style is applied if I change the button type to primary.

oooplz commented 2 years ago

You save my life. But the button style is still not working. No style is applied if I change the button type to primary.

export default defineNuxtConfig({
  css: [
    'element-plus/dist/index.css'
  ]
 })
polly3d commented 2 years ago

You save my life. But the button style is still not working. No style is applied if I change the button type to primary.

export default defineNuxtConfig({
  css: [
    'element-plus/dist/index.css'
  ]
 })

This doesn't work. I have already tried it. It only works on client only.

oooplz commented 2 years ago

Okay. trying to open a new issue, Its will help you.

YunYouJun commented 2 years ago

@vueuse/core/nuxt migrate to @vueuse/nuxt, we need to wait a little time.

xiaoxian521 commented 2 years ago

fix: https://github.com/element-plus/element-plus-nuxt-starter/commit/98aa178d5031359d67653e1b5f5f7611ab94ca1f