Can't use global installation of prettier when `addon-storysource` or `source-loader` is installed
See original GitHub issueDescribe the bug We can’t use a global installation of prettier in yarn scripts (or npm scripts) when certain storybook packages like @storybook/addon-storysource or @storybook/source-loader are installed.
To Reproduce
Steps to reproduce the behavior:
0. Run yarn global add prettier@2.0.5
to install prettier globally.
- Clone the repo https://github.com/manjunatha-d/storybook-prettier-issue-reproduction
- Run
yarn install
in the cloned repo - Run
yarn format
(the script format is defined asprettier --version && which prettier && prettier '*.js'
)
Expected behavior
prettier
should be a devDependency
of these addons. Is there any particular reason for declaring prettier
as a dependency
instead of devDependency
?
System: Environment Info:
System: OS: macOS High Sierra 10.13.6 CPU: (8) x64 Intel® Core™ i7-4770HQ CPU @ 2.20GHz Binaries: Node: 12.10.0 - ~/Projects/spark/.buildenv/bin/node Yarn: 1.21.0 - ~/Projects/spark/src/rubrik/spark-ui/node_modules/.bin/yarn npm: 6.10.3 - ~/Projects/spark/.buildenv/bin/npm Browsers: Chrome: 83.0.4103.116 Safari: 13.0.4 npmPackages: @storybook/addon-a11y: ^5.3.14 => 5.3.14 @storybook/addon-actions: ^5.3.14 => 5.3.14 @storybook/addon-backgrounds: ^5.3.14 => 5.3.14 @storybook/addon-docs: ^5.3.14 => 5.3.14 @storybook/addon-knobs: 5.3.14 => 5.3.14 @storybook/addon-links: ^5.3.18 => 5.3.18 @storybook/addon-storysource: ^5.3.14 => 5.3.14 @storybook/addon-viewport: ^5.3.14 => 5.3.14 @storybook/addons: ^5.3.14 => 5.3.14 @storybook/preset-create-react-app: ^1.5.2 => 1.5.2 @storybook/react: ^5.3.14 => 5.3.14
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
@shilman Alright, thanks!
For others with the same issue: We can make it work in monorepos by using path to the global prettier binary, something like:
Unfortunately those libraries do depend on prettier at the moment. I think there are some smaller alternatives we should consider using, but that’s a separate issue