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

createContentLoader data.posts.js resolved to an ESM file and cannot be loaded by require. 1.0.0-rc.45 #3655

Closed
4 tasks done
kfung21 opened this issue Mar 13, 2024 · 1 comment
Labels
bug: pending triage Maybe a bug, waiting for confirmation

Comments

@kfung21
Copy link

kfung21 commented Mar 13, 2024

Describe the bug

data.posts does not get read properly

Reproduction

https://stackblitz.com/~/github.com/kfung21/test-blog

Expected behavior

show blog posts

System Info

[ERROR] "vitepress" resolved to an ESM file. ESM file cannot be loaded by `require`. See https://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only for more details. [plugin externalize-deps]

Additional context

No response

Validations

@kfung21 kfung21 added the bug: pending triage Maybe a bug, waiting for confirmation label Mar 13, 2024
@0xlau
Copy link
Contributor

0xlau commented Mar 14, 2024

It's not a bug. You can review the NOTE in this topic.

NOTE

VitePress is an ESM-only package. Don't use require() to import it, and make sure your nearest package.json contains "type": "module", or change the file extension of your relevant files like .vitepress/config.js to .mjs/.mts. Refer to Vite's troubleshooting guide for more details. Also, inside async CJS contexts, you can use await import('vitepress') instead.

Solution

Make sure your nearest package.json contains "type": "module"

image

@brc-dd brc-dd closed this as completed Mar 14, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: pending triage Maybe a bug, waiting for confirmation
Projects
None yet
Development

No branches or pull requests

3 participants