storybook icon indicating copy to clipboard operation
storybook copied to clipboard

The requested module '/node_modules/jsdoc-type-pratt-parser/dist/index.js?v=dd771ee8' does not provide an export named 'parse'

Open tomrob270 opened this issue 1 year ago • 12 comments

Getting above error when adding storybook. It is correctly picking up .stories.ts files image

.storybook/main

import type { StorybookConfig } from "@storybook-vue/nuxt";

const config: StorybookConfig = {
  stories: [
    "stories/**/*.mdx",
    "stories/**/*.stories.@(js|jsx|mjs|ts|tsx)",
    "../components/**/*.stories.@(js|jsx|mjs|ts|tsx)",
  ],
  addons: [
    "@storybook/addon-links",
    "@storybook/addon-essentials",
    "@storybook/addon-interactions",
  ],
  framework: {
    name: "@storybook-vue/nuxt",
    options: {},
  },
  docs: {
    autodocs: "tag",
  },
};
export default config;

nuxt config

  modules: [
    "nuxt-quasar-ui",
    "@vueuse/nuxt",
    "@pinia/nuxt",
    "@pinia-plugin-persistedstate/nuxt",
    "@formkit/auto-animate/nuxt",
    "@hebilicious/vue-query-nuxt",
    "@nuxt/eslint",
    "@nuxtjs/i18n",
    "nuxt-monaco-editor",
    "nuxt-lodash",
    "@nuxtjs/storybook",
  ],

package.json

  "devDependencies": {
    "@nuxt/devtools": "latest",
    "@nuxt/eslint": "^0.5.0",
    "@nuxt/test-utils": "^3.14.0",
    "@nuxtjs/i18n": "latest",
    "@nuxtjs/storybook": "^8.2.0",
    "@pinia-plugin-persistedstate/nuxt": "^1.2.1",
    "@storybook/addon-essentials": "^8.3.1",
    "@types/jsurl": "^0.1.2",
    "@types/lodash": "^4.17.7",
    "@types/md5": "^2.3.5",
    "@types/sanitize-html": "^2.11.0",
    "drizzle-kit": "latest",
    "eslint": "^9.8.0",
    "eslint-plugin-prettier": "^5.1.3",
    "nuxt": "^3.11.2",
    "nuxt-lodash": "latest",
    "nuxt-monaco-editor": "latest",
    "nuxt-quasar-ui": "^2.0.6",
    "pg": "^8.11.3",
    "prettier": "^3.3.2",
    "sass": "^1.69.5",
    "typescript": "^5.4.5",
    "vite-plugin-node-polyfills": "^0.22.0",
    "vitest": "^2.0.4",
    "vue": "^3.3.10",
    "vue-component-type-helpers": "^2.0.6",
    "vue-router": "^4.2.5"
  },

tomrob270 avatar Sep 17 '24 12:09 tomrob270

Could you please provide a minimal reproduction In particular, test if one of the plugins are creating the issue. As a workaround, you may try to add jsdoc-type-pratt-parser to optimizeDeps.include.

tobiasdiez avatar Sep 17 '24 16:09 tobiasdiez

This appears to be introduced with 8.3.x in @storybook/core. This is not shown in the online examples linked to StackBlitz from the website. Those examples are currently experiencing a 404 bug looking for /sb-preview/runtime.js.

The workaround provided above for optimizeDeps.include does fix the problem.

CraigThatcher avatar Sep 18 '24 18:09 CraigThatcher

I got the same error; but the workaround does not work for me. I put jsdoc-type-pratt-parser to optimizeDeps.include within .storybook/main.ts, but then it show the same error with vue itself:

The requested module '/node_modules/vue/dist/vue.runtime.esm-bundler.js?v=89f1e65f' does not provide an export named 'useId'

package.json:

"devDependencies": {
    "@graphql-codegen/cli": "^5.0.2",
    "@graphql-codegen/near-operation-file-preset": "^3.0.0",
    "@graphql-codegen/typed-document-node": "^5.0.6",
    "@graphql-codegen/typescript": "^4.0.6",
    "@graphql-codegen/typescript-operations": "^4.2.0",
    "@nuxt/eslint": "^0.5.0",
    "@nuxt/eslint-config": "^0.5.0",
    "@nuxt/icon": "^1.2.1",
    "@nuxt/test-utils": "^3.13.1",
    "@nuxtjs/i18n": "8.5.2",
    "@nuxtjs/storybook": "~8.2.0",
    "@pinia/nuxt": "^0.5.1",
    "@storybook-vue/nuxt": "~8.2.0",
    "@storybook/addon-a11y": "~8.3.0",
    "@storybook/addon-essentials": "~8.3.0",
    "@storybook/addon-interactions": "~8.3.0",
    "@storybook/addon-links": "~8.3.0",
    "@storybook/blocks": "~8.3.0",
    "@storybook/test": "~8.3.0",
    "@types/node": "^20.0.0",
    "@urql/vue": "^1.3.2",
    "@vue/test-utils": "^2.4.6",
    "@vuepic/vue-datepicker": "^9.0.0",
    "@vueuse/core": "^11.0.0",
    "@vueuse/nuxt": "^11.0.0",
    "@vueuse/router": "^11.0.0",
    "dayjs-nuxt": "^2.1.9",
    "eslint": "^9.0.0",
    "eslint-config-prettier": "^9.1.0",
    "eslint-plugin-prettier": "^5.2.1",
    "happy-dom": "14.12.3",
    "husky": "^9.1.4",
    "lint-staged": "^15.2.7",
    "nuxt": "3.13.1",
    "nuxt-swiper": "^1.2.2",
    "pinia": "^2.1.7",
    "playwright-core": "^1.45.0",
    "prettier": "^3.3.3",
    "sass": "^1.78.0",
    "storybook": "~8.3.0",
    "typescript": "^4.9.3",
    "venobox": "^2.1.8",
    "vitest": "^1.6.0"
  },

.storybook/main.ts

import type { StorybookConfig } from '@storybook-vue/nuxt';
import { mergeConfig } from 'vite';

const config: StorybookConfig = {
  core: {
    disableTelemetry: true,
  },
  stories: ['../components/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
  addons: [
    '@storybook/addon-links',
    '@storybook/addon-essentials',
    '@storybook/addon-interactions',
    '@storybook/addon-a11y',
  ],
  framework: {
    name: '@storybook-vue/nuxt',
    options: {},
  },
  staticDirs: [{ from: '../public/assets', to: 'assets' }],
  async viteFinal(config) {
     return mergeConfig(config, {
      optimizeDeps: {
        include: ['jsdoc-type-pratt-parser'],
      }
    });
  }
};
export default config;

cheindl avatar Sep 18 '24 19:09 cheindl

Not sure if it'll make a difference @cheindl but try adding optimizeDeps.include: ['jsdoc-type-pratt-parser'] into nuxt.config.ts https://nuxt.com/docs/api/nuxt-config#vite

AtsMultanen avatar Sep 19 '24 08:09 AtsMultanen

Could you please provide a minimal reproduction In particular, test if one of the plugins are creating the issue. As a workaround, you may try to add jsdoc-type-pratt-parser to optimizeDeps.include.

This fixes the error

tomrob270 avatar Sep 19 '24 13:09 tomrob270

Let's try to find a proper solution for this (which might be that we always add the optimizeDeps entry in the module).

First, it would be good to know with which storybook version this occurs first. Is it 8.3.0 or 8.3.1? In the latter case, this might be triggered by https://github.com/storybookjs/storybook/pull/29134

tobiasdiez avatar Sep 19 '24 13:09 tobiasdiez

Let's try to find a proper solution for this (which might be that we always add the optimizeDeps entry in the module).

First, it would be good to know with which storybook version this occurs first. Is it 8.3.0 or 8.3.1? In the latter case, this might be triggered by storybookjs/storybook#29134

Also getting the same issue its a pretty new setup literally just been installing modules

Heres the current packag.json:

  "name": "nuxt-app",
  "private": true,
  "type": "module",
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "postinstall": "nuxt prepare"
  },
  "dependencies": {
    "@nuxt/fonts": "^0.8.0",
    "@nuxt/image": "^1.8.0",
    "@nuxtjs/seo": "^2.0.0-rc.21",
    "@nuxtjs/storybook": "^8.2.0",
    "nuxt": "^3.13.2",
    "sass": "^1.79.3",
    "vue": "^3.5.8",
    "vue-router": "^4.4.5"
  }
}


nathansmedley avatar Sep 23 '24 09:09 nathansmedley

I could now reproduce it in the upgrade PR to v. 8.3.2 https://github.com/nuxt-modules/storybook/pull/779, but storybook v 8.3.0 works. So either add the optimizeDep for now (until its fixed upstream with https://github.com/storybookjs/storybook/pull/29179) or force all storybook deps to be v8.3.0.

tobiasdiez avatar Sep 23 '24 09:09 tobiasdiez

Here's a repro with storybook@next, @storybook-vue/nuxt@nightly and @nuxtjs/storybook@nightly https://stackblitz.com/edit/nuxt-starter-vwzpyp?file=README.md,package.json

fdendorfer avatar Sep 27 '24 10:09 fdendorfer

Thanks @fdendorfer, but this still uses the old version '@storybook/builder-vite': 8.3.3([email protected])([email protected])([email protected]) without the fix. We have to wait for the release of storybook 8.4, and then use the updated version here in the module.

Until then use the workaround from https://github.com/nuxt-modules/storybook/issues/776#issuecomment-2360419016.

I'll pin this issue until its fixed.

tobiasdiez avatar Oct 07 '24 09:10 tobiasdiez

The optimizeDeps.include workaround doesn't work for us (v8.3.x and v8.4.0-alpha), but disabling the @storybook/addon-docs included by @storybook/addon-essentials did the trick:

// main.js
const config = {
  // ...
  addons: [
    // ...
    {
      name: '@storybook/addon-essentials',
      options: {
        // fix jsdoc-type-pratt-parser
        docs: false,
      }
    },
  ],
};

bojanrajh avatar Oct 18 '24 07:10 bojanrajh

Somehow, I needed to include jsdoc-type-prat-parser like below. (I'm using pnpm btw)

  vite: {
    optimizeDeps: {
      include: ['storybook > @storybook/core > jsdoc-type-pratt-parser'],
    },
  },

https://github.com/vitejs/vite/issues/10047 https://vite.dev/config/dep-optimization-options.html#optimizedeps-exclude

yshrsmz avatar Oct 24 '24 08:10 yshrsmz

@yshrsmz can confirm that works for me, however when storybook loads up in parallel with the pnpm dev command, i get a Pre-transform error: Failed to resolve import "/_nuxt/@vite-plugin-checker-runtime" from "virtual:@vite-plugin-checker-runtime-entry". Does the file exist? error. If i just use pnpm storybook, no error.

binaryartifex avatar Nov 03 '24 23:11 binaryartifex

__

Somehow, I needed to include jsdoc-type-prat-parser like below. (I'm using pnpm btw)

vite: { optimizeDeps: { include: ['storybook > @storybook/core > jsdoc-type-pratt-parser'], }, },

vitejs/vite#10047 https://vite.dev/config/dep-optimization-options.html#optimizedeps-exclude

Nice! This worked for me. Storybook runs now (Docker // PNPM // Nuxt 3:latest)


It seems some style are broken. Have to check this one

lafllamme avatar Nov 06 '24 18:11 lafllamme

nuxt-ds  | [nuxt:storybook:build]  ERROR  Context conflict
nuxt-ds  | 
nuxt-ds  |   at checkConflict (node_modules/.pnpm/[email protected]/node_modules/nuxi/dist/shared/nuxi.f56b6a0d.mjs:43:13)
nuxt-ds  |   at Object.set (node_modules/.pnpm/[email protected]/node_modules/nuxi/dist/shared/nuxi.f56b6a0d.mjs:77:9)
nuxt-ds  |   at initNuxt (node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_rollup@4._nz5a4uegooluwfsvugnjrc2mfa/node_modules/nuxt/dist/index.mjs:4375:11)
nuxt-ds  |   at Object.ready (node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected]_rollup@4._nz5a4uegooluwfsvugnjrc2mfa/node_modules/nuxt/dist/index.mjs:4277:18)
nuxt-ds  |   at defineNuxtConfig (node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]_@[email protected]_ro5oi4fjbgm4zgqkkunrccyht4/node_modules/@storybook-vue/nuxt/dist/preset.cjs:6744:14)
nuxt-ds  |   at async Object.viteFinal (node_modules/.pnpm/@[email protected]_@[email protected][email protected][email protected]_@[email protected]_ro5oi4fjbgm4zgqkkunrccyht4/node_modules/@storybook-vue/nuxt/dist/preset.cjs:6773:22)
nuxt-ds  |   at async createViteServer (node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_@[email protected]_hw2nzfy3in3jtgyk5soopfhe7e/node_modules/@storybook/builder-vite/dist/index.js:69:3611)
nuxt-ds  |   at async Module.start (node_modules/.pnpm/@[email protected][email protected][email protected][email protected]_@[email protected]_hw2nzfy3in3jtgyk5soopfhe7e/node_modules/@storybook/builder-vite/dist/index.js:69:4465)
nuxt-ds  |   at async storybookDevServer (node_modules/.pnpm/@[email protected][email protected]/node_modules/@storybook/core/dist/core-server/index.js:36065:11)
nuxt-ds  |   at async buildOrThrow (node_modules/.pnpm/@[email protected][email protected]/node_modules/@storybook/core/dist/core-server/index.js:35039:12)
nuxt-ds  | 
nuxt-ds  | 
nuxt-ds  | [nuxt:storybook:build]  WARN 
nuxt-ds  |           Broken build, fix the error above.
nuxt-ds  |           You may need to refresh the browser.
nuxt-ds  |         
nuxt-ds  | 
? Would you like to help improve Storybook by sending anonymous crash reports? › (Y/n)  ➜ DevTools: press Shift + Alt + D in the browser (v1.6.0)
nuxt-ds  | 
nuxt-ds  | ✔ Vite client built in 178ms
nuxt-ds  | ✔ Vite server built in 621ms
nuxt-ds  | [nitro] ✔ Nuxt Nitro server built in 608 ms
nuxt-ds  | ℹ Vite client warmed up in 2ms
nuxt-ds  | ℹ Vite server warmed up in 904ms

Happens for me with latest nuxt & vue, someone here with similar behaviour?

lafllamme avatar Nov 12 '24 19:11 lafllamme

👋 Hey there, fellow travelers of the package dependency maze!

So I stumbled upon this issue, and it seems like the command's adding extra packages by default? Or maybe it's just having some fun with us. 🤷‍♂️ Anyway, I thought I'd drop in a little something for all the lost souls who might land here, wondering why things aren’t working as expected.

Turns out, the commented fix below isn't even necessary. Yep, that's right.

import type { StorybookConfig } from "@storybook-vue/nuxt";
const config: StorybookConfig = {
  stories: [
    "../stories/**/*.mdx",
    "../stories/**/*.stories.@(js|jsx|mjs|ts|tsx)",
    "../stories/components/**/*.stories.@(js|jsx|mjs|ts|tsx|mdx)",
    "../stories/patterns/**/*.stories.@(js|jsx|mjs|ts|tsx|mdx)",
    "../stories/patterns/**/**/*.stories.@(js|jsx|mjs|ts|tsx|mdx)"
  ],
  addons: [
    "@storybook/addon-links",
    "@storybook/addon-interactions",
    "@storybook/addon-essentials",

  ],
  framework: {
    name: "@storybook-vue/nuxt",
    options: {},
  },
  docs: {
    autodocs: "tag",
  },
  // @ts-ignore
  vite: {
    // plugins: [],
    // fix below is not needed
    /*optimizeDeps: {
      include: ['storybook > @storybook/core > jsdoc-type-pratt-parser'],
    },*/
  },
};
export default config;

For your sanity, here’s the correct package.json setup for the latest Nuxt/Storybook adventure

"dependencies": {
    "nuxt": "latest",
    "vue": "latest",
    "vue-router": "latest"
  },
  "devDependencies": {
    "@chromatic-com/storybook": "^1.9.0",
    "@nuxtjs/storybook": "latest",
    "@storybook-vue/nuxt": "latest",
    "@storybook/addon-essentials": "8.4.2",
    "@storybook/addon-links": "8.4.2",
    "@storybook/addon-interactions": "8.4.2",
    "@storybook/addon-mdx-gfm": "8.4.2",
    "@storybook/blocks": "8.4.2",
    "@storybook/test": "8.4.2",
    "@types/node": "^18.17.5",
    "storybook": "8.4.2",
  },

This should hopefully make things smoother for the next traveler passing by. Safe coding, and may your package-lock.json always be in sync! 🚀

lafllamme avatar Nov 14 '24 20:11 lafllamme

@lafllamme does this work for you when running only nuxt dev and does it show up under your nuxt devtools? I haven't been able to get it to show on the devtools plus it doesn't seem to be registering the /_storybook route correctly 🤔

hacknug avatar Nov 15 '24 10:11 hacknug

Hi @hacknug,

Regarding your first question: Yes, when I run nuxt dev, everything works normally. I tested it with both (p)npm, and it worked fine. I haven’t tried Bun yet, as I’ve encountered inconsistencies with various packages and (sub)modules, so I decided to skip it for now.

I managed to configure my Vite setup to connect with Nuxt DevTools, but it didn’t work as expected. While I could see modules, tools, settings, and imported composables, I couldn’t view my Storybook components, routes, or similar items.

If you’re interested, I can share my configuration for you to explore. Perhaps you might notice something I missed. I also created a bug ticket for this, as it seems related to the @nuxt/devtools dev dependency.

Let me know if you want to collaborate on this further!

Best regards

lafllamme avatar Nov 19 '24 11:11 lafllamme

Thank you @lafllamme for guiding us on this journey! However, even though I've followed your package.json to the point, it wasn't the solution. Storybook starts up and than crashed with the error: ✘ [ERROR] The entry point "vue" cannot be marked as external.

We've been waiting for months in the hope this package gets fixed with no success so far. :(

melvinprindustry avatar Nov 19 '24 16:11 melvinprindustry

@melvinprindustry

Thanks for sharing your journey so far! Storybook starting up and then crashing is definitely not the destination we’re aiming for.

Try adding this to your config:

async viteFinal(config) {
  return mergeConfig(config, {
    resolve: {
      alias: {
        vue: 'vue/dist/vue.esm-bundler.js',
      },
    },
    // Uncomment this if you need devtools enabled
    // devtools: true,
  });
}

You can see an example of it in action here: https://github.com/lafllamme/Nuxt-Design-System/blob/master/app/.storybook/main.ts

Let us know if this helps get things running smoothly. If not, we’re happy to keep brainstorming with you!

lafllamme avatar Nov 30 '24 18:11 lafllamme

@lafllamme I'm very grateful for your help. Storybook seems to be working--for now. Thank you very much :) Though sometimes it "forgets" global components loaded through plugins. Like font-awesome-icon for example. But I'll be able to work around that :)

melvinprindustry avatar Dec 02 '24 15:12 melvinprindustry

The optimizeDeps workaround is now automatically applied (https://github.com/nuxt-modules/storybook/pull/792), which made it possible to finally upgrade to the latest version of storybook (at least our tests are passing, and locally it was working for me as well).

tobiasdiez avatar Dec 07 '24 16:12 tobiasdiez