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

ReferenceError: module is not defined #87

Closed
mivinci opened this issue Apr 25, 2021 · 5 comments
Closed

ReferenceError: module is not defined #87

mivinci opened this issue Apr 25, 2021 · 5 comments

Comments

@mivinci
Copy link

mivinci commented Apr 25, 2021

I am using bytemd in a SvelteKit app and errors occurred
image
image

Seems like Vite doesn't support CommonJS modules that bytemd imported. Has anyone encountered this situation or should I go SvelteKit and Vite for help?

@mivinci
Copy link
Author

mivinci commented Apr 25, 2021

Most likely it's a bug caused by SvelteKit's builtin Vite but I'm curious if anyone solved this problem in their SvelteKit apps.

@mivinci mivinci closed this as completed Apr 25, 2021
@pd4d10
Copy link
Owner

pd4d10 commented Apr 25, 2021

We have an example here https://github.com/bytedance/bytemd/blob/main/examples/svelte-kit/README.md

But there seems a little problem with the SSR process.

@mivinci
Copy link
Author

mivinci commented Apr 25, 2021

@pd4d10 Yep. I've tried to disable SSR both app-wide and on page-level according to https://kit.svelte.dev/docs#ssr-and-javascript-ssr but they didn't work for me. Finally, I found this error disappeared when previewing bundled version with sveltekit's node-adapter.
It is just Vite's problem I guess cuz a lot of people got the situation there https://github.com/vitejs/vite/issues?q=require+is+not+defined

@MarcGodard
Copy link

@mivinci Did you get it working? Having the same problem.

@CaptainCodeman
Copy link

We have an example here https://github.com/bytedance/bytemd/blob/main/examples/svelte-kit/README.md

But there seems a little problem with the SSR process.

The problem with that example is that it is using WebPack to create a separate package that the example then imports. This isn't how most users of SvelteKit are going to try to consume the package.

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