Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run prettier on windows

I want to add prettier into scripts in package.json.

Reading at the docs, it suggests doing the following using the cli

In practice, this may look something like:

prettier --single-quote --trailing-comma es5 --write "{app,__{tests,mocks}__}/**/*.js"

It works on mac / ubuntu but getting the following error message on windows.

[error] No matching files. Patterns tried: 'src/*.js' !**/node_modules/** !./node_modules/**
error Command failed with exit code 2.
like image 492
locropulenton Avatar asked Jan 03 '18 13:01

locropulenton


2 Answers

For Windows you have to escape the ", in the package.json will look like this:

"scripts": {
  "prettier": "prettier --single-quote --trailing-comma es5 --write \"{app,__{tests,mocks}__}/**/*.js\"",
},
like image 122
Lipis Avatar answered Oct 07 '22 09:10

Lipis


I encountered this issue most recently myself.

Here's what I did:

in my package.json file i added this to the scripts section:

  "scripts": {
    "format": "prettier --write src/**/*.js",
  }

Note that the path does not have its own set of quotes. That solved it for me

like image 36
ceoehis Avatar answered Oct 07 '22 09:10

ceoehis