storybook: npx sb init error: Unable to find versions of @storybook/react using yarn

What’s the problem? Whenever I try to run npx sb init in a project it fails with Unable to find versions of <dependency> using yarn error message.

Is there documentation on this? No

Additional context Kubuntu 20.04 Node v14.16.1 Yarn 1.22.10 npm 7.10.0

Examples:

$ npx sb init

 sb init - the simplest way to add a Storybook to your project. 

 • Detecting project type. ✓
 • Adding Storybook support to your "Create React App" based project
     Unable to find versions of @storybook/react using yarn

     Unable to find versions of @storybook/addon-links using yarn

     Unable to find versions of @storybook/addon-essentials using yarn

     Unable to find versions of @storybook/addon-actions using yarn

     Unable to find versions of @storybook/node-logger using yarn

     Unable to find versions of @storybook/preset-create-react-app using yarn

Does anybody knows what can I do?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 24 (1 by maintainers)

Most upvoted comments

I’m also getting possibly similiar error with vite + react + ts: tried cleaning cache it didn’t worked for me

OS : windows 11 React: 18.2.0 node : 20.11.1 npm: 10.8.0 typescript: 5.2.2 vite: 5.2.0

`Error: Unable to find versions of @storybook/cli using npm
at NPMProxy.runGetVersions (C:\***\***\AppData\Local\npm-cache\_npx\bc7e1e37fcb46ffc\node_modules\@storybook\core-common\dist\index.js:37:639)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async doInitiate (C:\***\***\AppData\Local\npm-cache\_npx\bc7e1e37fcb46ffc\node_modules\@storybook\cli\dist\generate.js:146:992)
at async withTelemetry (C:\***\***\AppData\Local\npm-cache\_npx\bc7e1e37fcb46ffc\node_modules\@storybook\core-server\dist\index.js:40:3599)
at async initiate (C:\***\***\AppData\Local\npm-cache\_npx\bc7e1e37fcb46ffc\node_modules\@storybook\cli\dist\generate.js:180:245)`

I managed to solve the problem following the following steps:

Step 1: Check npm and Node.js

Make sure you have Node.js and npm installed correctly. You can check the installed versions with the following commands:

node -v

Step 2: Clear npm cache

Sometimes cache issues can cause these types of errors. Clear the npm cache with the following command:

npm cache clean --force

Step 3: Update npm

Make sure you are using the latest version of npm:

npm install -g npm@latest

Step 4: Try installing the package again

After clearing the cache and updating npm, try installing the package that was having the problem again, in my case it was Storybook:

npx sb init

And done!

If anyone encounters this issue in the future, just use the npx sb init in another machine, either physical or virtual, to install storybook. Then, upload your project without node_modules to any git repo, and in your “faulty” machine just clone the project and run yarn install.

This seems like a bug, but unfortunately I don’t have enough time to fix it and I just used this workaround.

Hello @danpaldev I solved this using the following command.

npm uninstall -g create-react-app

then

npm install -g create-react-app

Update npm

Update npm worked for me

I am getting this same error

(node:6875) [DEP0040] DeprecationWarning: The punycodemodule is deprecated. Please use a userland alternative instead. (Usenode --trace-deprecation … to show where the warning was created) Error: Unable to find versions of @storybook/cli using npm

and I am not using CRA I am using Vite and React typescript

Hello @danpaldev I solved this using the following command. npm uninstall -g create-react-app then npm install -g create-react-app

Thanks for your help @Ayushsunny , unfortunately it didn’t work 😦

Hey @danpaldev Can you try this ?

Uninstalling Command:

npm uninstall -g create-react-app

installing Command:

npx create-react-app my-app

I am using Ubuntu 22.10. I had the same issue. The problem was that I had installed Node using Snap. I solved the problem by installing Node using NVM.

I have the same error when run npx storybook init

```
Unable to find versions of @storybook/react using npm

 Unable to find versions of @storybook/addon-links using npm

 Unable to find versions of @storybook/addon-essentials using npm

 Unable to find versions of @storybook/addon-actions using npm

 Unable to find versions of @storybook/addon-interactions using npm

 Unable to find versions of @storybook/testing-library using npm

or this go through it

The command is as below:

npm uninstall -g create-react-app && npm i -g npm@latest && sudo npm cache clean -f && npx create-react-app my-app

This is taken from one of the Stack Overflow posts.

https://stackoverflow.com/questions/64963796/create-react-app-is-not-working-since-version-4-0-1/65043610

Getting same error here with react + webpack + ts on a Mac.

npx storybook@latest init
Error: Unable to find versions of @storybook/cli using npm
    at NPMProxy.runGetVersions (/Users/radams/.npm/_npx/bc7e1e37fcb46ffc/node_modules/@storybook/core-common/dist/index.js:37:639)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async doInitiate (/Users/radams/.npm/_npx/bc7e1e37fcb46ffc/node_modules/@storybook/cli/dist/generate.js:146:992)
    at async withTelemetry (/Users/radams/.npm/_npx/bc7e1e37fcb46ffc/node_modules/@storybook/core-server/dist/index.js:40:3599)
    at async initiate (/Users/radams/.npm/_npx/bc7e1e37fcb46ffc/node_modules/@storybook/cli/dist/generate.js:180:245)

Try cleaning up npx and npm caches. Then re-run again. It worked for me.

or this go through it

The command is as below:

npm uninstall -g create-react-app && npm i -g npm@latest && sudo npm cache clean -f && npx create-react-app my-app

This is taken from one of the Stack Overflow posts.

https://stackoverflow.com/questions/64963796/create-react-app-is-not-working-since-version-4-0-1/65043610

@Ayushsunny Thanks for your rapid response. It seems that you are suggesting that the issue is related to create-react-app? I don’t have any problems creating CRA apps using npx, but I just tried it anyways as I don’t know why this issue is happening.

The only issue that I have is that npx sb init always throws those yarn errors on every react project. Maybe is just an issue related to storybook?