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

Module not found error with sveltekit and typescript #47

Closed
Jakeii opened this issue Jan 5, 2022 · 10 comments
Closed

Module not found error with sveltekit and typescript #47

Jakeii opened this issue Jan 5, 2022 · 10 comments

Comments

@Jakeii
Copy link

Jakeii commented Jan 5, 2022

Getting the following error with vite@2.7.10 and @sveltejs/kit@1.0.0-next.215

Cannot find module '/Users/.../node_modules/svelte-forms/form' imported from /Users/.../node_modules/svelte-forms/index.js
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/.../node_modules/svelte-forms/form' imported from /Users/.../plate-svelte-kit/node_modules/svelte-forms/index.js
    at new NodeError (node:internal/errors:371:5)
    at finalizeResolution (node:internal/modules/esm/resolve:416:11)
    at moduleResolve (node:internal/modules/esm/resolve:932:10)
    at defaultResolve (node:internal/modules/esm/resolve:1044:11)
    at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
    at link (node:internal/modules/esm/module_job:75:36)

can be reproduced by creating a new sveltekit project using npm init svelte@next my-app, installing, opting to use typescript and trying to use svelte-forms

@Jakeii Jakeii changed the title Module not found error Module not found error with sveltekit and typescript Jan 5, 2022
@chainlist
Copy link
Owner

Hi @Jakeii,

Indeed there is an error. I am on it.
I wonder why it stops working with SSR all of a sudden tho'

@Jakeii
Copy link
Author

Jakeii commented Jan 8, 2022

Hi @Jakeii,

Indeed there is an error. I am on it. I wonder why it stops working with SSR all of a sudden tho'

Changing all imports to include the file extensions seemed to fix it, not sure why, or if it breaks anything else though.

@chainlist
Copy link
Owner

Why do you mean by "to include the file extensions"?

That might be a error caused by a change in how vite resolve its dependencies.

@Jakeii
Copy link
Author

Jakeii commented Jan 8, 2022

Why do you mean by "to include the file extensions"?

That might be a error caused by a change in how vite resolve its dependencies.

Inside the svelte-forms module I changed all imports to include '.js' and it fixed the issue.

@chainlist
Copy link
Owner

That's interesting!

Thanks for your feedback

@Jakeii
Copy link
Author

Jakeii commented Jan 8, 2022

hey again @chainlist, have dug into this a bit. So I think svelte-forms should be including the '.js' according to the ES6 import spec. I think the reason it was working before was because vite was using commonjs to load ssr modules. It broke in 2.7.0 when vitejs/vite#5197 added native support for 'import' for ssr.

@chainlist
Copy link
Owner

chainlist commented Jan 9, 2022

Thanks for you digging!

I'm on it!

Tests need fixing with the new imports, but a new version is going to get released soon

@chainlist
Copy link
Owner

Issue has been fixed in the latest version 2.0.11.

Thanks for your precious help, it saved me a lot of investigation time! Much appreciated!

@hsb-tonmoy
Copy link

I'm still having this issue, with the latest version. Any idea why? #55

@xcorat
Copy link

xcorat commented May 20, 2022

Same... It comes up only when I refresh the page. The first load with the form works, but if I refresh the browser, it throws an error.. any suggestions?

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