Prettier formatter does not work out-of-the-box in VSCode 1.38.1 in NX NestJS application
See original GitHub issueExpected Behavior
When I use the prettier
format on a file inside the VSCode editor, it succeeds.
Current Behavior
When I use the prettier
format on a file inside the VSCode editor, it throws an error in the output tab of the terminal.
Failure Information (for bugs)
Steps to Reproduce
Please provide detailed steps for reproducing the issue.
npx create-nx-workspace@latest {whatever}
yarn add @nrwl/nest
nx g @nrwl/nest:application
- Run
prettier
on a badly formattedbroken-prettier/apps/src/app/app.module.ts
in VSCode - Get error:
Failed to load plugin '@nrwl/nx' declared in 'CLIOptions'/Users/aryanjabbari/Documents/Practice/broken-prettier/apps/src/app/app.module.ts:: Cannot find module '@nrwl/eslint-plugin-nx'
Require stack:
- /__placeholder__.js
Context
Please provide any relevant information about your setup:
- version of Nx used: 8.5.0
- 3rd-party libraries and their versions
package.json
:
{
...
"dependencies": {
"@nestjs/common": "^6.2.4",
"@nestjs/core": "^6.2.4",
"@nestjs/platform-express": "^6.2.4",
"reflect-metadata": "^0.1.12"
},
"devDependencies": {
"@nrwl/workspace": "8.5.0",
"@types/node": "~8.9.4",
"dotenv": "6.2.0",
"eslint": "6.1.0",
"prettier": "1.16.4",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.4.5",
"@nrwl/jest": "8.5.0",
"jest": "24.1.0",
"@types/jest": "24.0.9",
"ts-jest": "24.0.0",
"@nrwl/node": "8.5.0",
"@nestjs/schematics": "^6.3.0",
"@nestjs/testing": "^6.2.4",
"@nrwl/nest": "8.5.0",
"@nrwl/eslint-plugin-nx": "8.5.0",
"@typescript-eslint/parser": "2.0.0-alpha.4",
"@typescript-eslint/eslint-plugin": "2.0.0-alpha.4",
"eslint-config-prettier": "6.0.0"
}
}
- and most importantly - a use-case that fails: https://github.com/AryanJ-NYC/broken-prettier
Failure Logs
Failed to load plugin '@nrwl/nx' declared in 'CLIOptions'/Users/aryanjabbari/Documents/Practice/broken-prettier/apps/src/app/app.module.ts:: Cannot find module '@nrwl/eslint-plugin-nx'
Require stack:
- /__placeholder__.js
Other
VSCode Version: 1.38.1 esbenp.prettier-vscode extension version: 2.2.2
Issue Analytics
- State:
- Created 4 years ago
- Comments:5
Top Results From Across the Web
Code formatting with prettier is not working in nest js
Make sure prettier is enabled in VS Code; Check the "prettier" logs (open a terminal, select the "output" tab. next you need to...
Read more >How to fix Prettier Extension not working issue in VS CODE
0:00 · New! Watch ads now so you can enjoy fewer interruptions. Got it.
Read more >How to fix Prettier Extension in VS Code - YouTube
I just updated VS Code and my prettier extension (to format all of my code) was not working. I didn't realize how much...
Read more >Prettier not working in VSCode – possible fixes - LinuxPip
Prettier is an opinionated code formatter very popular in web development. It makes sure your code looks good and easy to read through....
Read more >Prettier - Code formatter - Visual Studio Marketplace
Settings can also be configured through VS Code - however, these settings will only apply while running the extension, not when running prettier...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
https://github.com/prettier/prettier-vscode/issues/672#issuecomment-526467711
I found the solution. VSCode has (had) a prettier.eslint setting that I had turned on (likely from a long, long time ago). It’s only with this eslint config that I’ve run into trouble. Sorry for the trouble and thanks for your time.
I am running macOS High Sierra, Version 10.13.6.