fumeapp / dayjs

Nuxt V3 module for Day.js
Apache License 2.0
112 stars 12 forks source link

dayjs-nuxt module error #42

Open iforgetyounow opened 4 months ago

iforgetyounow commented 4 months ago

Uncaught SyntaxError: The requested module '/_nuxt/node_modules/.pnpm/dayjs@1.11.11/node_modules/dayjs/dayjs.min.js?v=f805e27d' does not provide an export named 'default' (at dayjs.imports.mjs:3:8)

tcampbPPU commented 4 months ago

could you provide more detail or an example repo where this can be reproduced?

FabienVINCENT commented 4 months ago

@tcampbPPU I've same problem and create a minimal repo : https://github.com/FabienVINCENT/issue-nuxt-dayjs Note: I use pnpm and it is indeed him who created the problem because with npm no problem

tcampbPPU commented 4 months ago

@FabienVINCENT what version of PNPM are you using? i am using 9.3.0 and cloned your example repo (thank you btw for that) and its building fine for me image

FabienVINCENT commented 4 months ago

pnpm 9.3.0too

It's building but in console you have this error : image

tcampbPPU commented 4 months ago

@FabienVINCENT add this to your package.json file

"dayjs": "^1.11.11",

so in all you are looking like:

  "devDependencies": {
    "dayjs": "^1.11.11",
    "dayjs-nuxt": "^2.1.9"
  }
tcampbPPU commented 4 months ago

@FabienVINCENT idk why that extra import is needed but lmk if that at least clears up the error

FabienVINCENT commented 4 months ago

Yes I found this hack yesterday it actually gets rid of the error

tcampbPPU commented 4 months ago

let me look into why thats needed and i can update the readme so others dont get stuck on this, but hope this satisfies for now

RodrigoCarvalhoCode commented 3 months ago

Even with this:

@FabienVINCENT add this to your package.json file

"dayjs": "^1.11.11",

so in all you are looking like:

  "devDependencies": {
    "dayjs": "^1.11.11",
    "dayjs-nuxt": "^2.1.9"
  }

I'm having the same error.

SyntaxError: The requested module '/_nuxt/node_modules/dayjs/plugin/arraySupport.js?v=f769ff9e' does not provide an export named 'default' (at dayjs.imports.mjs:12:8)

how can you fix this?

tcampbPPU commented 3 months ago

@RodrigoCarvalhoCode Based on this error message it appears to be a different error, are you using additional dayjs plugins? If so could you create a new issue and provide a sample repo or your config.

RodrigoCarvalhoCode commented 3 months ago

So I've solved in a hacky way, when I was building my project in SSR mode on build, I had import errors. So I've solved it by adding to build transpile, like

build: {
        transpile: ['dayjs'],

And this fixed on build (for production), but it was raising that error that I've said before in local.

So I've tried checking if the process.env is production or not like

build: {
        transpile: isProd? ['dayjs']: [],

And this did the trick. Don't understand why the build step would affect vite locally, but this solved it for now.