Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tomrob270 opened this issue Sep 17, 2024 · 19 comments · Fixed by storybookjs/storybook#29179
Labels
status: blocked Blocked by an issue / missing feature of a dependency, or by another issue type: bug Something isn't working

Comments

@tomrob270
Copy link

tomrob270 commented Sep 17, 2024

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"
  },
@tobiasdiez
Copy link
Collaborator

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 tobiasdiez added type: bug Something isn't working status: needs reproduction Needs a minimal reproduction labels Sep 17, 2024
@CraigThatcher
Copy link

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.

@cheindl
Copy link

cheindl commented Sep 18, 2024

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;

@AtsMultanen
Copy link

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

@tomrob270
Copy link
Author

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

@tobiasdiez
Copy link
Collaborator

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

@tobiasdiez tobiasdiez reopened this Sep 19, 2024
tobiasdiez added a commit that referenced this issue Sep 22, 2024
<!--
☝️ PR title should follow conventional commits
(https://conventionalcommits.org).
In particular, the title should start with one of the following types:

- docs: 📖 Documentation (updates to the documentation or readme)
- fix: 🐞 Bug fix (a non-breaking change that fixes an issue)
- feat: ✨ New feature/enhancement (a non-breaking change that adds
functionality or improves existing one)
- feat!/fix!: ⚠️ Breaking change (fix or feature that would cause
existing functionality to change)
- chore: 🧹 Chore (updates to the build process or auxiliary tools and
libraries)
-->

### 🔗 Linked issue

<!-- If it resolves an open issue, please link the issue here. For
example "Resolves #123" -->

### 📚 Description

Add browser-based tests to verify that Storybook starts in development
mode. Aim is to catch errors like
#776

<!-- Describe your changes in detail -->
<!-- Why is this change required? What problem does it solve? -->
@nathansmedley
Copy link

nathansmedley commented Sep 23, 2024

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"
  }
}


@tobiasdiez
Copy link
Collaborator

tobiasdiez commented Sep 23, 2024

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

@fdendorfer
Copy link

fdendorfer commented Sep 27, 2024

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

@tobiasdiez
Copy link
Collaborator

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 #776 (comment).

I'll pin this issue until its fixed.

@tobiasdiez tobiasdiez added status: blocked Blocked by an issue / missing feature of a dependency, or by another issue and removed status: needs reproduction Needs a minimal reproduction labels Oct 7, 2024
@tobiasdiez tobiasdiez pinned this issue Oct 7, 2024
@bojanrajh
Copy link

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,
      }
    },
  ],
};

@yshrsmz
Copy link

yshrsmz commented Oct 24, 2024

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

@binaryartifex
Copy link

@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.

@lafllamme
Copy link

__

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
Copy link

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
Copy link

👋 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! 🚀

@hacknug
Copy link

hacknug commented Nov 15, 2024

@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 🤔

@lafllamme
Copy link

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

@melvinprindustry
Copy link

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. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: blocked Blocked by an issue / missing feature of a dependency, or by another issue type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.