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

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

Open lud-hu opened this issue 2 years ago • 15 comments

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 [email protected]: The engine "vscode" appears to be invalid.
[4/5] Linking dependencies...
warning " > @vitejs/[email protected]" has unmet peer dependency "vite@^4.0.0".
warning "nuxt-schema-org > @unhead/[email protected]" has unmet peer dependency "@unhead/vue@>=1.1.9".
warning " > [email protected]" has unmet peer dependency "webpack@^5.0.0".
warning " > [email protected]" has unmet peer dependency "vite@^3.0.0 || ^4.0.0".
warning " > @storybook/[email protected]" has unmet peer dependency "@vue/compiler-core@^3.0.0".
warning " > @storybook-vue/[email protected]" has unmet peer dependency "vite@^4.0.0".
warning "@storybook-vue/nuxt > @nuxt/[email protected]" has unmet peer dependency "vite@*".
warning "@storybook-vue/nuxt > @storybook/[email protected]" has unmet peer dependency "vite@^3.0.0 || ^4.0.0".
warning "@storybook-vue/nuxt > @storybook/[email protected]" has unmet peer dependency "vite@^3.0.0 || ^4.0.0".
warning "@storybook-vue/nuxt > @storybook/vue3-vite > @vitejs/[email protected]" 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

lud-hu avatar Aug 28 '23 06:08 lud-hu

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

chakAs3 avatar Aug 29 '23 15:08 chakAs3

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.

lud-hu avatar Sep 03 '23 16:09 lud-hu

@lud-hu can you try again

chakAs3 avatar Sep 08 '23 12:09 chakAs3

Unfortunately the same behaviour with [email protected] :(

lud-hu avatar Sep 12 '23 10:09 lud-hu

Unfortunately the same behaviour with [email protected] :(

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

chakAs3 avatar Sep 13 '23 01:09 chakAs3

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

usamatariqnetshore avatar Sep 25 '23 11:09 usamatariqnetshore

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

chakAs3 avatar Sep 26 '23 08:09 chakAs3

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

usamatariqnetshore avatar Sep 28 '23 04:09 usamatariqnetshore

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

chakAs3 avatar Sep 28 '23 07:09 chakAs3

@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

usamatariqnetshore avatar Sep 28 '23 07:09 usamatariqnetshore

@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 avatar Sep 28 '23 09:09 chakAs3

Live Demo

chakAs3 avatar Sep 28 '23 09:09 chakAs3

Live Demo

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

usamatariqnetshore avatar Sep 28 '23 10:09 usamatariqnetshore

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)
   |        ^
...

cernymatej avatar Oct 11 '23 19:10 cernymatej

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

mdigital123 avatar Oct 11 '23 21:10 mdigital123