jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.24k stars 508 forks source link

Storybook 6.0 React version 16.x not the same as `tsdx create` React version 17.x #916

Closed ghost closed 3 years ago

ghost commented 3 years ago

Current Behavior

When I run npx tsdx create mylib --template react-with-storybook I get this error:

Error: Command failed with exit code 1: npm install @babel/core @size-limit/preset-small-lib @storybook/addon-essentials @storybook/addon-info @storybook/addon-links @storybook/addons @storybook/react @types/react @types/react-dom babel-loader husky react react-dom react-is size-limit tsdx tslib typescript --save-dev
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: mylib@0.1.0
npm ERR! Found: react@17.0.1
npm ERR! node_modules/react
npm ERR!   dev react@"*" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0" from @storybook/addon-essentials@6.0.27
npm ERR! node_modules/@storybook/addon-essentials
npm ERR!   dev @storybook/addon-essentials@"*" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\Simon\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Simon\AppData\Local\npm-cache\_logs\2020-10-28T18_43_43_980Z-debug.log

    at makeError (C:\Users\Simon\AppData\Local\npm-cache\_npx\99d8f6679c19e750\node_modules\execa\lib\error.js:59:11)
    at handlePromise (C:\Users\Simon\AppData\Local\npm-cache\_npx\99d8f6679c19e750\node_modules\execa\index.js:114:26)
    at processTicksAndRejections (node:internal/process/task_queues:93:5)
    at async C:\Users\Simon\AppData\Local\npm-cache\_npx\99d8f6679c19e750\node_modules\tsdx\dist\index.js:173:9

npm ERR! code 1
npm ERR! path C:\Users\Simon\Projects
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c ""tsdx" "create" "mylib" "--template" "react-with-storybook""

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Simon\AppData\Local\npm-cache\_logs\2020-10-28T18_43_44_014Z-debug.log

Expected behavior

The project should be created without errors.

Suggested solution(s)

Upgrade storybook version to a version that uses react@17.0.1 (if it exists) or downgrade react to react@16.8.0.

Additional context

Your environment

  System:
    OS: Windows 10 10.0.19041
    CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
    Memory: 22.72 GB / 31.93 GB
  Binaries:
    Node: 15.0.1 - D:\Program Files\nodejs\node.EXE
    npm: 7.0.3 - D:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.423.0), Chromium (86.0.622.56)
    Internet Explorer: 11.0.19041.1
agilgur5 commented 3 years ago

Thanks for the bug report. Looks like React 17 just got out of RC last week. This a bug upstream as Storybook is working on React 17 support and has an alpha release of v6.1.0 that seems to support it (but is missing react-dom support).

I have a feeling this will be released shortly, so I'm not sure if action is warranted. But yes, create doesn't pin any specific version which means it always has latest without needing to change the code but which can also cause problems like this (or #810 ) where latest of one thing isn't compatible with everything else.

As you're probably aware, this can be manually fixed by manually downgrading in the meantime, so it shouldn't be a huge hindrance. I noticed you were using npm v7 which does have some different behavior regarding peerDeps, so that might complicate it a bit.

agilgur5 commented 3 years ago

Storybook 6.1.0 was released into stable on November 18th and supports React 17, so this is no longer an issue. Please upgrade your Storybook version if this still. affects you.