Getting an error 'No files matching the pattern were found' when using prettier

Viewed 12356

I found this answer how to format code using prettier

Here is what I've done

npm i prettier -g
prettier --write \"./**/*.{js,html}\"

Got an error [error] No files matching the pattern were found: ""./**/*.{js,html}"". any ideas how to fix? do you think it is because I installed the prettier globally (in the answer it is installed locally)?

So how would you use pettier when it is installed globally then?

5 Answers

Probably the quotes are wrong. It should probably be:

prettier --write "./**/*.{js,html}"

without the backslashes.

One solution to this problem was suggested here : and actually worked for me. Notice I am on Windows machine, so am not sure how it will behave on others. Just remove anything before and after the expression (quotes):

prettier --write ./**/*.{js,html}

the problem is with the quotes

I was using

prettier --write 'src//**/*.{js,jsx,json}'

here is how I fixed mine

prettier --write src//**/*.{js,jsx,json}

this was for errno 2

If you have a prettier script setup in package.json, you'll need to wrap the filepath in quotes, escape double quotes or use single quotes:

"prettier": "prettier 'src/**/*'"
"prettier": "prettier \"src/**/*\""

what worked for me is installing touch command globally using this command

npm install touch-cli -g

then create your .prettierrc file using the touch command

touch .prettierrc 

put simple configuration in the .prettierrc file like

{ "trailingComma": "es5","tabWidth": 4,"semi": false,"singleQuote":true}

then in the package.json file write the following script

  "scripts": {
"prettier":"npx prettier --config .prettierrc \"src/**/*.js\" --write"
             }

then run the script using npm command

npm run prettier
Related