question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't use global installation of prettier when `addon-storysource` or `source-loader` is installed

See original GitHub issue

Describe 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.

  1. Clone the repo https://github.com/manjunatha-d/storybook-prettier-issue-reproduction
  2. Run yarn install in the cloned repo
  3. Run yarn format (the script format is defined as prettier --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:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
manjunatha-dcommented, Jul 4, 2020

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

format: "path_to_dir_containing_global_prettier/prettier '*.js'"
0reactions
shilmancommented, Jul 4, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Install - Prettier
First, install Prettier locally:
Read more >
node.js - Prettier installed globally but command not found
I was trying to learn CLI tools and following the steps on MDN. And below is the problem I met. $ npm install...
Read more >
newwwton/addon-storysource - Storybook
First, install the addon yarn add @storybook/addon-storysource --dev. Add this line to your addons.js file import '@storybook/addon-storysource/register';.
Read more >
Install Prettier in VS Code - YouTube
Learn how to install Prettier in VS Code (Visual Studio Code). Once installed, you won't have to worry about code formatting as Prettier...
Read more >
pretty-quick - npm
Runs Prettier on your changed files. ... Supported source control managers: Git; Mercurial. Install. With yarn : yarn add --dev prettier pretty- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found