-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Cannot init in a new project #26553
Comments
I think you should |
npx installs the CLI if it isn't already available. Also, nowhere in the getting started guide it is mentioned that the CLI needs to be installed separately before. |
Have you tried clearing your npm cache and running again? |
Yes!
|
Out of curiosity, does this happen if you try to run |
Yes, I even tried that earlier. |
This is really strange. Does this command |
Yes, it does
|
Tried it again with 8.0.2; didn't work
|
Hi there! Thank you for opening this issue, but it has been marked as |
I'm afraid we need to close this issue for now, since we can't take any action without the requested reproduction or additional information. But please don't hesitate to open a new issue if the problem persists – we're always happy to help. Thanks so much for your understanding. |
Thought I should give it a try again and ran into this issue again. This time I tried to debug what's the case. It seems that the execCommand function at this line returns an empty string. The command execution went well. The console logs below proves that. ❯ npx storybook init
"8.0.9" <--- stdio inherit passed to execCommand
{ commandResult: '' } <--- It should have been "8.0.9"
Unexpected end of JSON input <--- json parsing on empty string
Error: Unable to find versions of @storybook/cli using npm |
@shilman Can you please reopen this issue? |
So, I went deep further, and learnt that the stdout from the command is undefined, which is very strange as neither stderr is defined.
{
commandResult: {
command: 'npm info @storybook/cli version --json',
escapedCommand: 'npm info "@storybook/cli" version --json',
exitCode: 0,
stdout: undefined,
stderr: undefined,
all: undefined,
failed: false,
timedOut: false,
isCanceled: false,
killed: false
}
} |
looks like something is wrong with execa. import {execa} from 'execa';
const commandResult = await execa('npm', ['info', '@storybook/cli', 'version', '--json']);
console.log(commandResult); ❯ node testexec.js
{
command: 'npm info @storybook/cli version --json',
escapedCommand: 'npm info "@storybook/cli" version --json',
exitCode: 0,
stdout: '',
stderr: '',
all: undefined,
failed: false,
timedOut: false,
isCanceled: false,
killed: false
} |
@pavitra-infocusp re-opened. so i guess we wait for the resolution in execa? thanks so much for digging in on this. 🙏 |
👋 I am Execa's co-maintainer. From the look of it, I do not think there is a bug with Execa there, but the issue at sindresorhus/execa#995 can track this. In terms of calling Execa in Storybook, I would recommend replacing More details: the
As you can see, the The storybook/code/lib/core-common/src/js-package-manager/JsPackageManager.ts Lines 566 to 574 in 7e1ee32
|
@ehmicky Thanks so much for helping out here (and for maintaining Execa -- you rock!!!). I'm not sure whether we are on Execa v5 out of laziness or there's something specific that's holding us back. I'll check with the team and we'll try to get it upgraded. Hopefully @pavitra-infocusp or one of the other folks who experienced this issue can confirm the fix. 🙏 |
I've been trying with Node: 20.12.1
EDIT: Despite not even using |
Confirming upgrade to npm 10.8.1 resolved the issue for me, as well. Thank you @yannbf!
|
Confirming, upgrading npm to 10.8.1 resolved the issue when using
|
Updating npm also fixed the issue for me. Thank you team. |
Looks like this has been resolved then! Thanks everyone for confirming the fix. |
I don't know why this still doesn't work for me :( I just started a new React + Vite project and I am still not able to init Storybook.
|
@pavitra-infocusp , last week Storybook |
Nope,
|
I tried using the
|
I just tried again with
|
I'll try to fix and send a PR. |
Still getting the error on Node: 22.0.9
|
I have the same problem, and I can't find any resourse to fix this problem. node version: v20.17 |
Has anyone found a solution? |
also getting this issue, again. |
@vanessayuenn appears that this is still an issue for some users, even on newer versions. |
This might be resolved by upgrading Execa and replacing |
In an empty directory,
I end up having to kill the process. When I do, there are only three files created in Choosing
|
I still have this issue. What should I do? |
Can you all please try out the latest version of storybook (8.4.0) by running |
Initializing Storybook in a fresh environment works fine. I ran the command in an empty directory and the wizard showed up but when I try to add Storybook to an existing React project, it fails. |
@okaeiz Can you provide a repo where Storybook fails to initialize? |
I've been having the same issue and came here to find a solution, but since none have been posted, I just decided to look into it myself. The problem seems to stem from a command executed that runs Here's the specific area that fails in /core/src/common/js-package-manager/NPMProxy.ts#L238-L264 along with the suggested fix protected async runGetVersions<T extends boolean>(
packageName: string,
fetchAllVersions: T
): Promise<T extends true ? string[] : string> {
- const args = [fetchAllVersions ? 'versions' : 'version', '--json'];
+ const args = [fetchAllVersions ? 'versions --json' : 'version'];
try {
const commandResult = await this.executeCommand({
command: 'npm',
args: ['info', packageName, ...args],
});
- const parsedOutput = JSON.parse(commandResult);
+ const parsedOutput = fetchAllVersions ? JSON.parse(commandResult) : commandResult;
if (parsedOutput.error?.summary) {
// this will be handled in the catch block below
throw parsedOutput.error.summary;
}
return parsedOutput;
} catch (error) {
throw new FindPackageVersionsError({
error,
packageManager: 'NPM',
packageName,
});
}
} The same command in pnpm also returns the same semantic version which when parsed as JSON will also fail. I'll submit a PR for this unless someone else get to it before I do. EDIT: Looks like the root cause is related to npm. Older versions would output |
I found that a lot of the I noticed that most people here are using Node 22. The error I had is slightly different though (no error, just hangs indefinitely). |
I'm also encountering this issue. I have a Deno 2.0, Vite, React, SWC project I've now run three different commands:
yarn dlx storybook@latest init➤ YN0000: ┌ Resolution step SB_CLI_0001 (FindPackageVersionsError): Unable to find versions of "storybook" using Yarn Berry
npx storybook@latest init╭──────────────────────────────────────────────────────╮ npm error code EUNSUPPORTEDPROTOCOL And finally, deno run -A npm:storybook@latest init❯ deno run -A npm:storybook@latest init npm ERR! code EUNSUPPORTEDPROTOCOL npm ERR! A complete log of this run can be found in: /Users/aceaspades/.npm/_logs/2024-12-08T02_01_57_167Z-debug-0.log Noticing the error message stating that I need a yarn dlx storybook@latest init➤ YN0000: ┌ Resolution step SB_CLI_0001 (FindPackageVersionsError): Unable to find versions of "storybook" using Yarn Berry Finally, I ran deno run -A npm:storybook@latest init❯ deno run -A npm:storybook@latest init npm WARN reify invalid or damaged lockfile detected removed 8 packages, and audited 1 package in 773ms found 0 vulnerabilities ? Do you want to manually choose a Storybook project type to install? › |
Describe the bug
I am trying to install Storybook in a new project. But when I run
npx storybook@latest init
, it says "Error: Unable to find versions of @storybook/cli using npm"To Reproduce
Run
npx storybook@latest init
System
Additional context
The text was updated successfully, but these errors were encountered: