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

bug(nuxt-content): could not load file `mdc-imports.mjs`

Open miclgael opened this issue 2 years ago • 5 comments

Hello, and thank you for taking initiative in this module!

My set-up includes Nuxt Content, and produces this error on macOS 12.2.1 (21D62) Monterey

ℹ Building Nitro Server (preset: node-server)                                                             nitro 8:31:53 am

[nitro 8:31:57 am]  ERROR  Error: Could not load file:///Users/<REDACTED>/Code/projects/<REDACTED>/.nuxt/mdc-imports.mjs (imported by node_modules/.pnpm/@[email protected]/node_modules/@nuxtjs/mdc/dist/runtime/parser/index.mjs): ENOENT: no such file or directory, open 'file:///Users/<REDACTED>/Code/projects/<REDACTED>/.nuxt/mdc-imports.mjs'


undefined

Error: Error: Could not load file://./.nuxt/mdc-imports.mjs (imported by node_modules/.pnpm/@[email protected]/node_modules/@nuxtjs/mdc/dist/runtime/parser/index.mjs): ENOENT: no such file or directory, open 'file://./.nuxt/mdc-imports.mjs'
    at defineNuxtConfig (./node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected][email protected]_q6xcmcxyhuuik33x6btbuqlzni/node_modules/@storybook-vue/nuxt/dist/preset.cjs:79:11)
    at async Object.viteFinal (./node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected][email protected]_q6xcmcxyhuuik33x6btbuqlzni/node_modules/@storybook-vue/nuxt/dist/preset.cjs:97:22)
    at async createViteServer (./node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@storybook/builder-vite/dist/index.js:159:10530)
    at async Module.start (./node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@storybook/builder-vite/dist/index.js:159:12527)

WARN Broken build, fix the error above.
WARN You may need to refresh the browser.

 ELIFECYCLE  Command failed with exit code 1.

Things tried

  1. I confirmed the file it is looking for does indeed exist.
  2. I tried disabling mdc in Nuxt Content, but this didn't help.
  3. I tried making a repro for you but for some reason Storybook just hung and never launched :(

miclgael avatar Sep 29 '23 23:09 miclgael

Getting the issue as well

daniellacosse avatar Nov 06 '23 04:11 daniellacosse

Hi @daniellacosse - any chance you could do up a reproduction? Not sure what I was doing wrong :3

miclgael avatar Nov 06 '23 07:11 miclgael

I'm not using Storybook, but I have this exact same issue with a Nuxt 3 programmatic build.

I have a working version (a "reproduction") and a non-working version (my app). Both builds work without the content module.

The difference seems to be tsconfig.server.json.

tsconfig.server.json - not working

      "#mdc-imports": [
        "./file:/home/michael/causing-us/friend-server/.quasar/electron/baseLayer/.nuxt/mdc-imports"
      ],

tsconfig.server.json - working

      "#mdc-imports": [
        "./mdc-imports"
      ],

Not sure how to debug this. Why does it use a file: protocol?

MichaelJCole avatar Nov 10 '23 18:11 MichaelJCole

I'm getting the same error with my project which is using Nuxt Content and Nuxt UI Pro. I can reproduce it by installing the nuxt-ui-pro saas template (https://github.com/nuxt-ui-pro/saas) with npx nuxi init -t github:nuxt-ui-pro/saas and then doing the standard storybook install. You'll need a NUXT_UI_PRO_LICENSE to create a production build so maybe the nuxt ui guys can get you one to test it out. I don't think the error is UI Pro though, I think it's Content because of the MDC component.

Just thought you could try this as a repro. Might even be able to use Content Wind to see the error, https://github.com/atinux/content-wind

richard-edwards avatar Jan 21 '24 22:01 richard-edwards

So I just quickly confirmed the Content Wind has the same issue.

Easy repro:

npx nuxi@latest init -t themes/content-wind my-website

npm install -D @nuxtjs/storybook 

// edit nuxt.config.js
export default defineNuxtConfig(
{
  modules: ['@nuxtjs/storybook']
})

npx storybook-nuxt init

pnpm run storybook

[nitro 5:58:07 p.m.]  ERROR  Error: Could not load file:///home/richard/skunkworks/my-website/.nuxt/mdc-imports.mjs (imported by node_modules/.pnpm/@[email protected]/node_modules/@nuxtjs/mdc/dist/runtime/parser/index.mjs): ENOENT: no such file or directory, open 'file:///home/richard/skunkworks/my-website/.nuxt/mdc-imports.mjs'


undefined

=> Failed to build the preview
Error: Error: Could not load file://./.nuxt/mdc-imports.mjs (imported by node_modules/.pnpm/@[email protected]/node_modules/@nuxtjs/mdc/dist/runtime/parser/index.mjs): ENOENT: no such file or directory, open 'file://./.nuxt/mdc-imports.mjs'
    at defineNuxtConfig (./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/@storybook-vue/nuxt/dist/preset.cjs:6676:11)
    at async Object.viteFinal (./node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/@storybook-vue/nuxt/dist/preset.cjs:6697:22)
    at async createViteServer (./node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@storybook/builder-vite/dist/index.js:159:10562)
    at async Module.start (./node_modules/.pnpm/@[email protected][email protected][email protected]/node_modules/@storybook/builder-vite/dist/index.js:159:12804)

WARN Broken build, fix the error above.
WARN You may need to refresh the browser.

Hope this helps

richard-edwards avatar Jan 21 '24 23:01 richard-edwards