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

Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension. #4462

Closed
4 tasks done
zarar2312 opened this issue Jan 3, 2025 · 8 comments
Labels
need more info Further information is requested

Comments

@zarar2312
Copy link

Is your feature request related to a problem? Please describe.

As you can see in the image, it gives such an error. and this error started yesterday. Even though I didn't change any code

Describe the solution you'd like

image

Describe alternatives you've considered

No response

Additional context

No response

Validations

@brc-dd brc-dd closed this as not planned Won't fix, can't repro, duplicate, stale Jan 3, 2025
@brc-dd brc-dd reopened this Jan 3, 2025
@brc-dd
Copy link
Member

brc-dd commented Jan 3, 2025

Please provide a minimal reproducible example using https://vitepress.new

@brc-dd brc-dd added bug: pending triage Maybe a bug, waiting for confirmation need more info Further information is requested labels Jan 3, 2025
@zarar2312
Copy link
Author

node_modules\dayjs\esm\index.js:1
import * as C from './constant';
^^^^^^

What is the source of this error? The system, which normally works while building, is clearly not working yesterday.

@brc-dd
Copy link
Member

brc-dd commented Jan 3, 2025

I can’t tell without looking at your code first. You or maybe one of your deps might be using dayjs. You might’ve updated something which started breaking.

@zarar2312
Copy link
Author

[17:54:47.690] Running build in Washington, D.C., USA (East) – iad1
[17:54:47.849] Cloning github.com/zarar2312/GG-Crazy (Branch: main, Commit: fc0ad9f)
[17:54:48.366] Previous build cache not available
[17:54:48.443] Cloning completed: 595.466ms
[17:54:49.047] Running "vercel build"
[17:54:50.339] Vercel CLI 39.2.0
[17:54:50.977] Installing dependencies...
[17:55:18.520]
[17:55:18.520] added 251 packages in 27s
[17:55:18.521]
[17:55:18.521] 62 packages are looking for funding
[17:55:18.521] run npm fund for details
[17:55:19.013]
[17:55:19.013] �[32m�[1mvitepress�[22m v1.5.0�[39m
[17:55:19.013]
[17:55:19.204] - building client + server bundles...
[17:55:25.698] �[32m✓�[0m building client + server bundles...
[17:55:25.721] �[31mbuild error:�[39m
[17:55:25.722] Cannot find module '/vercel/path0/node_modules/dayjs/esm/constant' imported from /vercel/path0/node_modules/dayjs/esm/index.js
[17:55:25.722] Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/vercel/path0/node_modules/dayjs/esm/constant' imported from /vercel/path0/node_modules/dayjs/esm/index.js
[17:55:25.722] at finalizeResolution (node:internal/modules/esm/resolve:275:11)
[17:55:25.722] at moduleResolve (node:internal/modules/esm/resolve:932:10)
[17:55:25.722] at defaultResolve (node:internal/modules/esm/resolve:1056:11)
[17:55:25.722] at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:654:12)
[17:55:25.722] at #cachedDefaultResolve (node:internal/modules/esm/loader:603:25)
[17:55:25.722] at ModuleLoader.resolve (node:internal/modules/esm/loader:586:38)
[17:55:25.722] at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:242:38)
[17:55:25.722] at ModuleJob._link (node:internal/modules/esm/module_job:135:49)
[17:55:25.756] Error: Command "vitepress build docs" exited with 1
[17:55:25.938]

@brc-dd
Copy link
Member

brc-dd commented Jan 3, 2025

Like I said, we can't help without looking at actual code. Logs don't help. Please share a minimal reproducible example.

dayjs doesn't work properly with node's ESM resolution logic (iamkun/dayjs#1765). You might need to set vite: { ssr: { noExternal: ['dayjs'] } } in your .vitepress/config.ts file.

@brc-dd brc-dd removed the bug: pending triage Maybe a bug, waiting for confirmation label Jan 3, 2025
@zarar2312
Copy link
Author

Thank you bro.

@brc-dd
Copy link
Member

brc-dd commented Jan 4, 2025

Was this fixed?

@zarar2312
Copy link
Author

Yes fixid
image
image
no problem <3

@brc-dd brc-dd closed this as completed Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need more info Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants