storybook-nuxt icon indicating copy to clipboard operation
storybook-nuxt copied to clipboard

Windows - ERR_UNSUPPORTED_ESM_URL_SCHEME

Open Pecral opened this issue 2 years ago • 9 comments

Problems

  • Checkout https://github.com/storybook-vue/storybook-nuxt-starter master
  • update "@storybook-vue/nuxt" to 0.1.5
  • pnpm install
  • pnpm storybook

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

  • On windows 10/11
  • Nodejs 18.17.1 or Nodejs 20.6.1

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

Do you have any ideas?

Pecral avatar Oct 01 '23 20:10 Pecral

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?

Ingramz avatar Oct 02 '23 14:10 Ingramz

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

chakAs3 avatar Oct 03 '23 10:10 chakAs3

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

tobiasdiez avatar Oct 03 '23 10:10 tobiasdiez

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 avatar Oct 03 '23 10:10 chakAs3

@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

chakAs3 avatar Oct 03 '23 12:10 chakAs3

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.

Ingramz avatar Oct 03 '23 15:10 Ingramz

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`

tobiasdiez avatar Oct 03 '23 16:10 tobiasdiez

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

daviddomkar avatar Feb 12 '24 21:02 daviddomkar

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

daviddomkar avatar Feb 12 '24 21:02 daviddomkar