storybook-vue / storybook-nuxt

Deprecated in favor of https://github.com/nuxt-modules/storybook/
https://github.com/nuxt-modules/storybook/
134 stars 20 forks source link

Windows - ERR_UNSUPPORTED_ESM_URL_SCHEME #71

Open Pecral opened 1 year ago

Pecral commented 1 year ago

Problems

image

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'

Environment

The problem was reproducible on two different windows 10/11 machines.

Do you have any ideas?

Ingramz commented 1 year ago

I'm encountering this issue as well. Quick debugging led me to the following line https://github.com/storybook-vue/storybook-nuxt/blob/d6ddde06ec778a7128e484bf668975aef8b4d558/packages/storybook-nuxt/src/preset.ts#L132 where require.resolve returns full path to file, generally starting with C: on windows, which the import function does not like. Other usages of import(require.resolve(..)) fail in similar manner.

Is there any reason why await import('@storybook/vue3-vite/preset') can't just be used?

chakAs3 commented 12 months ago

@tobiasdiez i will do some tests on Windows, would please create a reproduction repo for me?

tobiasdiez commented 12 months ago

Perfect, I think it should already occur in the demo (see issue description), but here is also a real world repo: https://github.com/JabRef/JabRefOnline/pull/2244

chakAs3 commented 12 months ago

where require.resolve returns full path to file, generally starting with C: on windows, which the import function does not like. Other usages of import(require.resolve(..)) fail in similar manner.

you are completely right, this was some legacy code from storybook codebase, i did not pay attention to it since it is not breaking on Mac, but yeah should work fine, Thanks @Ingramz

chakAs3 commented 12 months ago

@tobiasdiez , @Ingramz would please test now, https://stackblitz.com/~/github.com/storybook-vue/storybook-nuxt-demo. on Windows, if it is fine i will release new version

Ingramz commented 12 months ago

0.1.6-alpha.5 didn't work, but 0.1.6-alpha.6 seems to be fine.

build-storybook finishes without errors and storybook starts up the development web server, but there's something else wrong that doesn't build or load the stories properly. But that's out of the scope of this specific issue, which seems to be solved now.

tobiasdiez commented 12 months ago

I can confirm this error is fixed. However, I now get issues of the following form suggesting that the resolution of the nuxtlink is not working (not sure if its windows-specific):

ode_modules@storybook-vue
untimecomponents
uxt-link" from "D:/Programming/JabRefOnline/node_modules/@nuxt/content/dist/runtime/components/ContentNavigation.vue".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
daviddomkar commented 7 months ago

Hello. I am still encountering this issue with latest version on Windows. Is there any fix for it?

daviddomkar commented 7 months ago

From additional testing I can confirm that version 0.2.1 works. But 0.2.2 and newer throws this exact error.