Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prettier formatter does not work out-of-the-box in VSCode 1.38.1 in NX NestJS application #1856

Closed
AryanJ-NYC opened this issue Sep 18, 2019 · 6 comments

Comments

@AryanJ-NYC
Copy link

AryanJ-NYC commented Sep 18, 2019

Expected 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.

  1. npx create-nx-workspace@latest {whatever}
  2. yarn add @nrwl/nest
  3. nx g @nrwl/nest:application
  4. Run prettier on a badly formatted broken-prettier/apps/src/app/app.module.ts in VSCode
  5. 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"
  }
}

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

@jdpearce
Copy link
Collaborator

Thanks, @AryanJ-NYC - can you provide a little more detail on how to reproduce this?

I've tried the steps you give and tried with your repo and prettier runs fine for me in both of them. I also have the same extension version.

How are you running it? Are you using yarn format?

@AryanJ-NYC
Copy link
Author

AryanJ-NYC commented Sep 18, 2019

Sure. Sorry for the lack of detail.

I went into broken-prettier/apps/src/app/app.module.ts and broke the formatting a bit (added tons of extra lines, specifically).

From here, neither yarn format nor the command palette's Format Document work.

Thanks for taking the time out to try and reproduce this. I'm mostly hoping this is somehow my local machine (but also hope to get Prettier working).

Edit: Also edited OP with specific file.

@jdpearce
Copy link
Collaborator

Thanks. I noticed the broken app.module.ts as that's what yarn format fixed when I ran it.
What OS are you running?

@AryanJ-NYC
Copy link
Author

I am running macOS High Sierra, Version 10.13.6.

@AryanJ-NYC
Copy link
Author

prettier/prettier-vscode#672 (comment)

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.

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants