node.jsgit-bashprettier

How do I get rid of this error? Prettier: [error] No supported files were found in the directory: "views"


I keep getting the following error when I run Prettier in the cli.

[error] No supported files were found in the directory: "views".

I am running:

Node v20.16.0 On:

Windows 11

I am building an API using Express. I have included the following .prettierignore:

**/*.html
views 
node_modules

And the following .prettierrc:

{
   "tabWidth": 3,
   "useTabs": false,
   "singleQuote": true,
   "jsxSingleQuote": true
}

And the following Git BASH version:

bash --version
GNU bash, version 5.2.26(1)-release (x86_64-pc-msys)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

Prettier is working fine, in that it's formatting my JS documents. I just want to get rid of the error at the end of the script's processing. Any ideas how to accomplish this?


Solution

  • Is the views folder located at the same folder level as the .prettierignore? Maybe doing the ignore like this would solve your issue?

    **/*.html
    **/views <<< add the views like this???
    node_modules
    

    Following this docs https://prettier.io/docs/en/ignore

    Or you can go and add a .prettierignore inside the views folder with the following content:

    file: views/.prettierignore

    *
    

    this will instruct prettier to ignore everything inside that folder you can check that at this article: https://devinschumacher.com/how-to-disable-prettier-formatting-for-individual-files-or-folders/

    I prefer to use the prettier doc instruction, and set it as the first option mentioned, but if the second option solves your problem go for it!