storybook-vue / storybook-nuxt

Deprecated in favor of https://github.com/nuxt-modules/storybook/
https://github.com/nuxt-modules/storybook/
134 stars 20 forks source link

Error during setup: could not find a copy of typescript to link #51

Open lud-hu opened 1 year ago

lud-hu commented 1 year ago

I get an error during setup and cannot complete to put storybook into my existing nuxt project.

$ npx storybook-nuxt init
YARN1 error: An unexpected error occurred: "could not find a copy of typescript to link in /.../node_modules/@storybook/vue3-vite/node_modules".

Please check the logfile generated at ./storybook.log for troubleshooting and try again.

     Error: YARN1 error: An unexpected error occurred: "could not find a copy of typescript to link in /.../node_modules/@storybook/vue3-vite/node_modules".

Please check the logfile generated at ./storybook.log for troubleshooting and try again.
    at Yarn1Proxy.addDependencies (/.../node_modules/@storybook/cli/dist/generate.js:3038:15)
    at async baseGenerator (/.../node_modules/@storybook/cli/dist/generate.js:4625:5)
    at async generator18 (/.../node_modules/@storybook/cli/dist/generate.js:5082:3)
    at async installStorybook (/.../node_modules/@storybook/cli/dist/generate.js:5212:12)
    at async doInitiate (/.../node_modules/@storybook/cli/dist/generate.js:5311:25)
    at async withTelemetry (/.../node_modules/@storybook/core-server/dist/index.js:113:4155)
    at async initiate (/.../node_modules/@storybook/cli/dist/generate.js:5354:26)

storybook.log:


yarn add v1.22.19
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
warning vscode-languageclient@7.0.0: The engine "vscode" appears to be invalid.
[4/5] Linking dependencies...
warning " > @vitejs/plugin-vue@4.2.3" has unmet peer dependency "vite@^4.0.0".
warning "nuxt-schema-org > @unhead/schema-org-vue@0.6.0" has unmet peer dependency "@unhead/vue@>=1.1.9".
warning " > sass-loader@13.3.2" has unmet peer dependency "webpack@^5.0.0".
warning " > vite-plugin-vue-type-imports@0.2.5" has unmet peer dependency "vite@^3.0.0 || ^4.0.0".
warning " > @storybook/vue3@7.4.0-alpha.2" has unmet peer dependency "@vue/compiler-core@^3.0.0".
warning " > @storybook-vue/nuxt@0.0.4" has unmet peer dependency "vite@^4.0.0".
warning "@storybook-vue/nuxt > @nuxt/devtools-kit@0.7.6" has unmet peer dependency "vite@*".
warning "@storybook-vue/nuxt > @storybook/vue3-vite@7.4.0-alpha.2" has unmet peer dependency "vite@^3.0.0 || ^4.0.0".
warning "@storybook-vue/nuxt > @storybook/builder-vite@7.4.0-alpha.2" has unmet peer dependency "vite@^3.0.0 || ^4.0.0".
warning "@storybook-vue/nuxt > @storybook/vue3-vite > @vitejs/plugin-vue@4.3.3" has unmet peer dependency "vite@^4.0.0".
error An unexpected error occurred: "could not find a copy of typescript to link in /.../node_modules/@storybook/vue3-vite/node_modules".
info If you think this is a bug, please open a bug report with the information provided in "/.../yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
% node --version
v18.16.1
% npm --version
9.5.1
% yarn --version
1.22.19
chakAs3 commented 1 year ago

@lud-hu please remove your npx cache and rerun npx storybook-nuxt init

lud-hu commented 1 year ago

Thanks @chakAs3 ! This did at least help for the initialization of storybook. Unfortunately I cannot add a story afterwards:

Error: Build failed with 5 errors:
node_modules/nuxt/dist/app/entry.js:3:24: ERROR: Could not resolve "#build/paths.mjs"
node_modules/nuxt/dist/app/entry.js:5:7: ERROR: Could not resolve "#build/css"
node_modules/nuxt/dist/app/entry.js:6:20: ERROR: Could not resolve "#build/plugins"
node_modules/nuxt/dist/app/entry.js:7:26: ERROR: Could not resolve "#build/root-component.mjs"
node_modules/nuxt/dist/app/entry.js:8:26: ERROR: Could not resolve "#build/nuxt.config.mjs"

The UI complains with:

Failed to fetch dynamically imported module: http://localhost:6006/node_modules/.cache/sb-vite/deps/@storybook_vue3_preview.js?v=d53314b2

I'm using nuxt 3.6.5.

chakAs3 commented 1 year ago

@lud-hu can you try again

lud-hu commented 1 year ago

Unfortunately the same behaviour with storybook-nuxt@0.1.0-rc.8 :(

chakAs3 commented 1 year ago

Unfortunately the same behaviour with storybook-nuxt@0.1.0-rc.8 :(

can you use the demo repo or create a fresh reproduction repo for me so i check it out, it is difficult to catch the issue in your system

usamatariqnetshore commented 1 year ago

This resolves by removing these imports from this path node_modules/nuxt/dist/app/entry.js it works but it seems not the correct method to make this work

chakAs3 commented 1 year ago

This resolves by removing these imports from this path node_modules/nuxt/dist/app/entry.js it works but it seems not the correct method to make this work

your idea is relevant i tried to avoid this i felt not right thing, let me dig this path thanks

usamatariqnetshore commented 1 year ago

This resolves by removing these imports from this path node_modules/nuxt/dist/app/entry.js it works but it seems not the correct method to make this work

your idea is relevant i tried to avoid this i felt not right thing, let me dig this path thanks

great if you do have any update please share. Thanks

chakAs3 commented 1 year ago

@usamatariqnetshore please here a working demo using latest version https://stackblitz.com/~/github.com/storybook-vue/storybook-nuxt-demo

usamatariqnetshore commented 1 year ago

@usamatariqnetshore please here a working demo using latest version https://stackblitz.com/~/github.com/storybook-vue/storybook-nuxt-demo

Thanks tried it. unfortunately similar issues are there in file node_modules/@storybook-vue/nuxt/dist/preview.mjs:4:20: 4 │ import plugins from '#build/plugins';

  and 2 similar imports.
  kindly check
chakAs3 commented 1 year ago

@usamatariqnetshore please here a working demo using latest version https://stackblitz.com/~/github.com/storybook-vue/storybook-nuxt-demo

Thanks tried it. unfortunately similar issues are there in file node_modules/@storybook-vue/nuxt/dist/preview.mjs:4:20: 4 │ import plugins from '#build/plugins';

  and 2 similar imports.
  kindly check

are you sure ? here is embed https://stackblitz.com/edit/nuxt-starter-cvzvzg?embed=1&file=package.json

chakAs3 commented 1 year ago

Live Demo

usamatariqnetshore commented 1 year ago

Live Demo

great. it works here.thanks to get updated version do i have to npx storybook-nuxt init ? apologies for my noob questions

cernymatej commented 1 year ago

I am also getting this error, however, clearing the cache didn't solve it in my case. My path of the package is a little different: error An unexpected error occurred: "could not find a copy of typescript to link in <path_to_project>/node_modules/@storybook-vue/nuxt/node_modules/@storybook/vue3-vite/node_modules


Edit: When I changed the @storybook-vue/nuxt version to 0.1.4-alpha.1 like in the live demo, the dependencies installed fine. But I am getting the following errors

ERROR  Transform failed with <number> errors: 
The symbol "_withScopeId" has already been declared
120|  import { createTextVNode as _createTextVNode, resolveComponent as _resolveComponent, withCtx as _withCtx, createVNode as _createVNode, toDisplayString as _toDisplayString, createElementVNode as _createElementVNode, vShow as _vShow, withDirectives as _withDirectives, openBlock as _openBlock, createElementBlock as _createElementBlock, pushScopeId as _pushScopeId, popScopeId as _popScopeId } from "vue"
121|  
122|  const _withScopeId = n => (_pushScopeId("data-v-52dc9ada"),n=n(),_popScopeId(),n)
   |        ^
...
mdigital123 commented 1 year ago

fyi i used pnpm instead of yarn and it worked perfectly. npm worked as well