storybook icon indicating copy to clipboard operation
storybook copied to clipboard

npx sb init ends abruptly with EBADPLATFORM error

Open spoike opened this issue 3 years ago • 16 comments

Describe the bug Installing storybook on a create react app based project appears to crash on Windows due to usage of fsevents. *snip-snip* added in logs below for NDA reasons.

> $ 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[..................] / reify: 
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"darwin"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS:    darwin
npm ERR! notsup Valid Arch:  undefined
npm ERR! notsup Actual OS:   win32
npm ERR! notsup Actual Arch: x64

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\*snip-snip*\AppData\Local\npm-cache\_logs\2021-04-01T11_23_32_108Z-debug.log   
 An error occurred while installing dependencies.

The following folders are added: .storybook and stories. Nothing is changed in package.json.

npm run storybook doesn't work either as script is missing:

npm ERR! Missing script: "storybook"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

The debug log from npm-cache ends with this:

2018 timing idealTree:node_modules/cpy/node_modules/path-type/node_modules/pify Completed in 0ms
2019 timing idealTree:buildDeps Completed in 36192ms
2020 timing idealTree:fixDepFlags Completed in 28ms
2021 timing idealTree Completed in 36944ms
2022 timing command:install Completed in 36953ms
2023 verbose stack Error: Unsupported platform
2023 verbose stack     at checkPlatform (C:\ProgramData\nvm\v15.13.0\node_modules\npm\node_modules\npm-install-checks\index.js:35:25)
2023 verbose stack     at Arborist.[checkPlatform] (C:\ProgramData\nvm\v15.13.0\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:235:5)
2023 verbose stack     at C:\ProgramData\nvm\v15.13.0\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:228:33
2023 verbose stack     at async Arborist.buildIdealTree (C:\ProgramData\nvm\v15.13.0\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:212:7)
2023 verbose stack     at async Promise.all (index 1)
2023 verbose stack     at async Arborist.reify (C:\ProgramData\nvm\v15.13.0\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:131:5)
2023 verbose stack     at async Install.install (C:\ProgramData\nvm\v15.13.0\node_modules\npm\lib\install.js:137:5)
2024 verbose pkgid [email protected]
2025 verbose cwd C:\Projects\*snip-snip*
2026 verbose Windows_NT 10.0.19042
2027 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--legacy-peer-deps" "-D" "@storybook/react@^6.2.1" "@storybook/addon-links@^6.2.1" "@storybook/addon-essentials@^6.2.1" "@storybook/addon-actions@^6.2.1" "@storybook/node-logger@^6.2.1" "@storybook/preset-create-react-app@^3.1.7"
2028 verbose node v15.13.0
2029 verbose npm  v7.7.6
2030 error code EBADPLATFORM
2031 error notsup Unsupported platform for [email protected]: wanted {"os":"darwin"} (current: {"os":"win32","arch":"x64"})
2032 error notsup Valid OS:    darwin
2032 error notsup Valid Arch:  undefined
2032 error notsup Actual OS:   win32
2032 error notsup Actual Arch: x64
2033 verbose exit 1

To Reproduce Steps to reproduce the behavior:

  1. npx sb init

Expected behavior No errors, and with package.json updated with required packages and a storybook task.

Screenshots Not applicable

Code snippets Not applicable

System Results of npx sb@next info:

Environment Info:

System: OS: Windows 10 10.0.19042 CPU: (12) x64 Intel(R) Core(TM) i7-10850H CPU @ 2.70GHz Binaries: Node: 15.13.0 - C:\Program Files\nodejs\node.EXE npm: 7.7.6 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: Spartan (44.19041.423.0), Chromium (89.0.774.63)

Additional context

  • Create react app installed [email protected].
  • Using typescript template for create-react-app

spoike avatar Apr 01 '21 11:04 spoike

I tried to install one of the deps (@storybook/[email protected]) from the last command stated in the debug log and it also fails with the same error.

> npm i --legacy-peer-deps -D @storybook/[email protected]
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"darwin"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS:    darwin
npm ERR! notsup Valid Arch:  undefined
npm ERR! notsup Actual OS:   win32
npm ERR! notsup Actual Arch: x64

spoike avatar Apr 01 '21 11:04 spoike

@tooppaaa you use windows right? ever seen this?

shilman avatar Apr 01 '21 11:04 shilman

All good on my side with a fresh create-react-app using the same command. However I'm running node 12. Any chance you can downgrade and let us know @spoike ?

tooppaaa avatar Apr 01 '21 17:04 tooppaaa

I've switched over to 12.22.0 with nvm for windows. And npx sb init works with a caveat on different version on package-log.json:

 • Adding Storybook support to your "Create React App" based project[..................] / rollbackFailedOptional: verb npm-sessionnpm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!

However fsevents is correctly skipped (since it's only for mac):

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\webpack-dev-server\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\watchpack-chokidar2\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

Running npm run storybook works on 12.22.0 (after fixing all the prettier errors from the generated files 😄)

You can do the following on 15.13.0 after successful run of npx sb init with 12.22.0:

  • npm run storybook works
  • npm ci works
  • Removing node_modules and npm i works (lol what ❓)

spoike avatar Apr 06 '21 09:04 spoike

Tried to issue the npx sb init command on the following versions:

  • 15.13.0 - doesn't work, EBADPLATFORM error
  • 14.16.0 - works
  • 12.22.0 - works

edit: I accidentally ran 15 instead of 14, but can confirm it works on 14.

spoike avatar Apr 06 '21 09:04 spoike

I get the same issue, but for a Vue application.


 • Detecting project type. ✓
 • Adding Storybook support to your "Single File Components Vue" app. ✓
 • Preparing to install dependencies. ✓



up to date, audited 2753 packages in 4s

5 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
. ✓

To run your Storybook, type:

   npm run storybook 

For more information visit: https://storybook.js.org

npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"darwin"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS:    darwin
npm ERR! notsup Valid Arch:  undefined
npm ERR! notsup Actual OS:   win32
npm ERR! notsup Actual Arch: x64

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\riksm\AppData\Local\npm-cache\_logs\2021-04-08T22_09_05_026Z-debug.log
An error occurred while installing dependencies.```

I'm using Node 14.16.1, tested both npm 6.14.12 and npm 7.9.0 on Windows 10 at the moment. The project I'm trying to add Storybook to is https://github.com/AEGEE/frontend

Edit: same project is running fine on Ubuntu

WikiRik avatar Apr 08 '21 22:04 WikiRik

Tried to issue the npx sb init command on the following versions:

  • 15.13.0 - doesn't work, EBADPLATFORM error
  • 14.16.0 - works
  • 12.22.0 - works

edit: I accidentally ran 15 instead of 14, but can confirm it works on 14.

Not working in v14.16.0

SonuTheDev avatar Apr 27 '21 16:04 SonuTheDev

I didn't check what npm version I used on 14.16.0, but it could be related to npm rather than node instead (since it fails due to the --legacy-peer-deps flag)?

spoike avatar Apr 29 '21 08:04 spoike

This might be related to this issue on npm/cli project, where EBADPLATFORM is treated as an error rather than a warning:

https://github.com/npm/cli/issues/2921

spoike avatar Apr 29 '21 08:04 spoike

My case

npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"darwin"} (current: {"os":"linux","arch":"x64"})
npm ERR! notsup Valid OS:    darwin
npm ERR! notsup Valid Arch:  undefined
npm ERR! notsup Actual OS:   linux
npm ERR! notsup Actual Arch: x64

change package-lock.json

"node_modules/fsevents": {
      "version": "2.3.2",
      .
      .
      .
      "os": [
        "darwin",
      ],
      "engines": {
        "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
      }
    },

to

"node_modules/fsevents": {
      "version": "2.3.2",
      .
      .
      .
      "os": [
        "darwin",
        "linux"// <<<<<<<<<<<<<<<<<<<<<<<<
      ],
      "engines": {
        "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
      }
    },

will you try add "os":["win32"] ??

WonBeomChoi avatar Apr 30 '21 06:04 WonBeomChoi

Hade the same issue, installed latest Node (v16.3.0) with npm v7.15.1 and it seems to work fine now. Running react v17.0.2.

charliearaya avatar Jun 07 '21 14:06 charliearaya

I still have the same issue running npx sb init on Node 16.1.0 with npm 7.24.2 for React 17.0.2 project (created using CRA)

npm ERR! code EBADPLATFORM npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"darwin"} (current: {"os":"win32","arch":"x64"}) npm ERR! notsup Valid OS: darwin npm ERR! notsup Valid Arch: undefined npm ERR! notsup Actual OS: win32 npm ERR! notsup Actual Arch: x64

ken-bekov avatar Oct 06 '21 07:10 ken-bekov

Same issue on node v18.17.0 and npm 9.6.7 when run this command on React 18 project

• Installing dependencies npm ERR! code EBADPLATFORM npm ERR! notsup Unsupported platform for @next/[email protected]: wanted {"os":"darwin","cpu":"arm64"} (current: {"os":"darwin","cpu":"x64"}) npm ERR! notsup Valid os: darwin npm ERR! notsup Actual os: darwin npm ERR! notsup Valid cpu: arm64 npm ERR! notsup Actual cpu: x64

SunnySun1027 avatar Jan 24 '24 01:01 SunnySun1027

@SunnySun1027 Do you have @next/swc-darwin-arm64 as a dependency listed in your package.json? I am curious why it tries to install it, although you are on a platform, which obviously doesn't support that package.

Could you also go through these possible fixes?

valentinpalkovic avatar Jan 24 '24 08:01 valentinpalkovic

3q, That's right! The project used the @next/swc-darwin-arm64 package and I installed by --force command then saved into my package.json. npx sb init will kindly to add the "--force " parameter to install the project dependencies.

SunnySun1027 avatar Jan 25 '24 09:01 SunnySun1027

May I ask you why @next/swc-darwin-arm64 is installed as a separate package? As far as I know, it is not necessary to install it separately.

valentinpalkovic avatar Jan 25 '24 13:01 valentinpalkovic