This error is related to Windows Line endings being different from Unix ones. Try running npx prettier --write . on your project's directory. This command will tell prettier to fix simple errors (such as this one) when found.
To prevent this error from happening again you can either set "end-of-line" to auto on your .prettierrc file or try setting line endings to "Unix"/LF on your editor: instructions for VSCode and for IntelliJ-based editors
This error is related to Windows Line endings being different from Unix ones. Try running npx prettier --write . on your project's directory. This command will tell prettier to fix simple errors (such as this one) when found.
To prevent this error from happening again you can either set "end-of-line" to auto on your .prettierrc file or try setting line endings to "Unix"/LF on your editor: instructions for VSCode and for IntelliJ-based editors
in your .prettierrc file, add this: "endOfLine": "auto"
» npm install prettier
node.js - prettier command not working even though prettier is in devDependancies - Stack Overflow
How do I use the CLI to fix all files?
Prettier CLI does not work with npm v7 (ERROR: prettier not found)
Code style issues found in the above file(s). Forgot to run Prettier? - Stack Overflow
» npm install eslint-plugin-prettier
» npm install prettier-eslint
» npm install prettier-eslint-cli
Installing a module that includes a CLI program like prettier, nodemon, etc., will place the program in node_modules/.bin. Your terminal shell does not know to look in this folder when you run a command. Type echo $PATH in your terminal to see a list of the folders that are checked when you run a command. You'll see that running prettier will be looking in places like /bin, /usr/bin, /usr/local/bin, etc., but definitely not /var/folders/q6/npwl_7xj4wg91lg06f8pnnfh0000gn/T/node_modules.
This is why npx is often used; from their docs:
Executes either from a local node_modules/.bin, or from a central cache, installing any packages needed in order for to run.
You could also run it via ./node_modules/.bin/prettier, or you could install it globally, as you ultimately did, which will put it in a place that is part of your $PATH.
After trying a bunch of things, I noticed it only affected this one folder. So what finally worked was simply cloning the repo again into a different folder.
so ive been messing around with create-react-app, ive probably set it up dozens of times now to try to debug why prettier wont work. I also get a bunch of vulnerabilities in the console once i do install prettier (but it still wont work). here is my process.
npx create-react-app test npm install --save-dev --save-exact prettier 1. added 1 package, and audited 1497 packages in 2s 236 packages are looking for funding run `npm fund` for details 74 vulnerabilities (69 moderate, 5 high) To address issues that do not require attention, run: npm audit fix To address all issues (including breaking changes), run: npm audit fix --force Run `npm audit` for details.
ignore the warnings and make a new .prettierrc.json in the root directory of the project. I paste the following into the prettier config:
{
"semi": true, "singleQuote": true, "tabWidth": 2, "trailingComma": "es5", "printWidth": 80 }I add .eslintrc.json to the root directory as well, and then i add this to it:
{ "extends": ["react-app", "react-app/jest", "plugin:prettier/recommended"], "rules": {
"prettier/prettier": ["error"] } } i press ctrl + , to make sure format on save is checked in the settings of vscode. i also make sure that the prettier extension is installed from the vs code store
I open and close back vscode, make a bad formatting on purpose like :
let x_______________ = 5. (the ____ are spaces with spacebar)
and i expect that when i press ctrl + s, it will remove the spaces, or even add the semicolon at the end, but it doesnt. prettier doesnt work at all. here is my repo: https://github.com/ForkEyeee/test
i guess my questions are: why do i get all of those vulnerabilties? is this normal cause all i do is start a new cra, then install prettier and i get so many errors. also, cra supports eslint out of the box, but not prettier, so is my install process of prettier correct. i even tried vite briefly and i had the same issue as webpack.