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

dayjs-nuxt module error #42

Open
iforgetyounow opened this issue Jul 11, 2024 · 11 comments
Open

dayjs-nuxt module error #42

iforgetyounow opened this issue Jul 11, 2024 · 11 comments

Comments

@iforgetyounow
Copy link

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

@tcampbPPU
Copy link
Member

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

@FabienVINCENT
Copy link

FabienVINCENT commented Jul 15, 2024

@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
Copy link
Member

@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
Copy link

FabienVINCENT commented Jul 15, 2024

pnpm 9.3.0too

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

@tcampbPPU
Copy link
Member

@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
Copy link
Member

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

@FabienVINCENT
Copy link

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

@tcampbPPU
Copy link
Member

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
Copy link

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
Copy link
Member

@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
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants