#Svelte 4 - Storybook 7 - Errors
20 messages · Page 1 of 1 (latest)
extranet@0.0.1 /home/thibault/Gitlab/MyApp
└─┬ @storybook/testing-library@0.2.0
└─┬ @testing-library/dom@9.3.1
└─┬ aria-query@5.1.3
└─┬ deep-equal@2.2.2
└─┬ regexp.prototype.flags@1.5.1
└── set-function-name@2.0.0
Looks like it's a known issue: https://github.com/ljharb/set-function-name/issues/1
for now I bet you can install functions-have-names manually
Is there no solution? 🤔
You can install it manually
npm i -D functions-have-names or whatever package manager you use
@crystal sparrow or @wild matrix any idea why the types would be failing on the default svelte example?
<script lang="ts">
export let primary = false
export let backgroundColor: string | undefined = undefined
export let size: 'small' | 'medium' | 'large' = 'medium'
export let label: string = ''
$: mode = primary ? 'storybook-button--primary' : 'storybook-button--secondary'
$: style = backgroundColor ? `background-color: ${backgroundColor}` : ''
</script>
<button
type="button"
class={['storybook-button', `storybook-button--${size}`, mode].join(' ')}
{style}
on:click
>
{label}
</button>
import type { Meta, StoryObj } from '@storybook/svelte'
import Button from './Button.svelte'
const meta = {
title: 'Composants/Button',
component: Button,
tags: ['autodocs'],
argTypes: {
backgroundColor: { control: 'color' },
size: {
control: { type: 'select' },
options: ['small', 'medium', 'large']
}
}
} satisfies Meta<Button>
export default meta
type Story = StoryObj<typeof meta>
export const Primary: Story = {
args: {
primary: true,
label: 'Button'
}
}
Other example with small adjustments 🤡
This looks like a mismatch version between Svelte 3 and 4.
Is there any way you have Svelte 3 somewhere hanging around?
"@playwright/test": "^1.28.1",
"@storybook/addon-essentials": "^7.0.0-beta.51",
"@storybook/addon-interactions": "^7.0.0-beta.51",
"@storybook/addon-links": "^7.0.0-beta.51",
"@storybook/blocks": "^7.0.0-beta.51",
"@storybook/svelte": "^7.0.0-beta.51",
"@storybook/svelte-vite": "^7.0.0-beta.51",
"@storybook/sveltekit": "^7.5.0-alpha.2",
"@storybook/testing-library": "^0.0.14-next.1",
"@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/adapter-node": "^1.2.3",
"@sveltejs/kit": "^1.24.1",
"@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0",
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-storybook": "^0.6.10",
"eslint-plugin-svelte3": "^4.0.0",
"functions-have-names": "^1.2.3",
"prettier": "^2.8.0",
"prettier-plugin-svelte": "^2.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"storybook": "7.4.1",
"svelte": "3.55.1",
"svelte-check": "^3.4.3",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^4.4.2",
"vitest": "^0.32.2"
OK
Go to "@sveltejs/kit": "^1.25.0", and "svelte": "^4.2.0",
Ah I see, you're using a pretty old version of all the Storybook packages, that don't support Svelte 4. I suggest you upgrade them all with "npx storybook@lastest upgrade"
I also see you have a newer version of @storybook/sveltekit, how did you end up in the situation of having different versions of the Storybook packages?
I think it's with cmd npx sb init
or npx storybook@next init
Storybook + Svelte lacks the documentation you need to understand everything. And the csf plugin doesn't work for me.
Maybe versionning problem
And your command :
npx storybook@lastest upgrade
npm ERR! code ETARGET
npm ERR! notarget No matching version found for storybook@lastest.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
Sorry I mistyped. It's npx storybook@latest upgrade
I installed storybook into an existing sveltekit project -- but Storybook cannot find my components, which are in src/lib/components -- was I expecting too much?, now I get generic links to storybook help pages
It works, but every other time I can't get the yarn storybook command to work
Because :
yarn run v1.22.19
warning ../../package.json: No license field
$ storybook dev -p 6006
🔴 Error: It looks like you are having a known issue with package hoisting.
Please check the following issue for details and solutions: https://github.com/storybookjs/storybook/issues/22431#issuecomment-1630086092
/home/thibault/Gitlab/MyApp/node_modules/cli-table3/src/utils.js:1
const stringWidth = require('string-width');
I have to delete my node_modules and yarn.lock and make a new yarn.