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 · 14 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

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.