storybook: npx sb init ends abruptly with EBADPLATFORM error

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 fsevents@2.3.1: 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 fsevents@2.3.1
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 fsevents@2.3.1: 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® Core™ 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 react-scripts@4.0.1.
  • Using typescript template for create-react-app

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 16 (4 by maintainers)

Most upvoted comments

My case

npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for fsevents@2.3.2: 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"] ??

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.

@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?

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

> npm i --legacy-peer-deps -D @storybook/react@6.2.1
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for fsevents@2.3.1: 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