storybook: [Bug]: [v7] storybook crashes with ERR_UNSUPPORTED_ESM_URL_SCHEME with vite builder and yarn pnp on windows
Describe the bug
In a clean install of storybook in a project configured to use yarn v3 / pnp, running the script “storybook” on windows leads to the following error:
ERR! Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'
ERR! at __node_internal_captureLargerStackTrace (node:internal/errors:478:5)
ERR! at new NodeError (node:internal/errors:387:5)
ERR! at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:1017:11)
ERR! at defaultResolve (node:internal/modules/esm/resolve:1097:3)
ERR! at nextResolve (node:internal/modules/esm/loader:163:28)
ERR! at resolve$1 (file:///D:/repositories/storybook-yarn/.pnp.loader.mjs:1966:14)
ERR! at nextResolve (node:internal/modules/esm/loader:163:28)
ERR! at ESMLoader.resolve (node:internal/modules/esm/loader:837:30)
ERR! at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
ERR! at ESMLoader.import (node:internal/modules/esm/loader:521:22)
ERR! at importModuleDynamically (node:internal/modules/cjs/loader:1094:29)
ERR! at importModuleDynamicallyWrapper (node:internal/vm/module:438:21)
ERR! at importModuleDynamically (node:vm:389:46)
ERR! at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
ERR! at getPreviewBuilder (D:\repositories\storybook-yarn\.yarn\cache\@storybook-core-server-npm-7.0.0-beta.15-b304f2875e-321ca5d8ec.zip\node_modules\@storybook\core-server\dist\index.js:10:1913)
ERR! at buildDevStandalone (D:\repositories\storybook-yarn\.yarn\cache\@storybook-core-server-npm-7.0.0-beta.15-b304f2875e-321ca5d8ec.zip\node_modules\@storybook\core-server\dist\index.js:33:2139)
ERR! at processTicksAndRejections (node:internal/process/task_queues:96:5)
Basically the error is because is missing file:/// prefix in module specifier
To Reproduce
I created a repository with a newly configured yarn pnp and clean install of storybook:
https://github.com/blikblum/yarn-storybook
Steps:
yarn set version stable
yarn init
yarn add --dev vite
npx sb@next init --builder=vite
Choose web-components type
yarn add --dev @storybook/builder-vite (is not added automatically)
yarn storybook
System
System:
OS: Windows 10 10.0.19045
CPU: (8) x64 Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
Binaries:
Node: 18.12.1 - C:\Program Files\nodejs\node.EXE
Yarn: 3.3.1 - ~\AppData\Roaming\npm\yarn.CMD
npm: 8.10.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.1266.0), Chromium (108.0.1462.46)
vite: ^4.0.3
storybook: 7.0.0-beta.15
Additional context
I tried also with yarn canary (v4) without success
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 8
- Comments: 18 (9 by maintainers)
Ooh-la-la!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.0-beta.17 containing PR #20430 that references this issue. Upgrade today to the
@nextNPM tag to try it out!Closing this issue. Please re-open if you think there’s still more to do.
storybook-sidebar-urlis a showcase repo, I do not maintain it or provide support for it due to time limitations. I also generally speaking do not support non-POSIX operating systems.There’s a hint here with
c:in the error message that this could be a Windows compatibility issue. See https://github.com/storybookjs/storybook/pull/20430/files#diff-fed81323d1084bcbecbbf0016c47ae40af46b4d9abc041fa8a9f0fcae32ff896R21 for an example fix in this here issue. You could do the same to replace the failing relative import, or you could use WSL to have a better-behaving development environment.