Running Prettier From The Terminal

If you do not have prettier installed globally, we can add it using yarn.

$ yarn global add prettier

Running Prettier In The Terminal

We can run Prettier against a file we want to format by just using the terminal. For example, if we run this:

$ prettier --single-quote --print-width=120 FilesName.js

Our terminal will show us what the file would look like formatted, but it will not actually format the actual file for us. If we want to format the actual file, we would have to include --write in our command, before the filename. So we would run,

$ prettier --single-quote --print-width=120 --write FilesName.js

Leave a Reply

avatar