-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
Failed to load plugin 'prettier' declared in '.eslintrc.js': Cannot find module 'eslint-plugin-prettier' #396
Comments
I met across the same problem. Exactly the same devDependencies. |
What command do you run? |
I found the reason why the error occurs. It's the reason of version of ESlint. |
@kevinprotoss I just tested it, and eslint-plugin-prettier works well with ESLint v7.21.0. (That ESLint v7.16.0 is mentioned in the changelog is completely useless. That’s just an internal commit that affects no users of this plugin. If I had written the changelog I wouldn’t have mentioned it.) What command do you run? |
@lydell I just saw this error message in the output console of VSCode. I did not try using the command. I just want the VSCode extension to do the autofix for me. |
I'm running across this issue as well all of a sudden in my shareable config (https://github.com/j0hnm4r5/eslint-config). All of the other dependencies are installing as expected when I install my config in a new project, but I'm not sure what the issue is here; did something change recently with npm or eslint maybe? It looks like the last update to this package was about 2 months ago, but I'm pretty sure I was able to install correctly in another project after that. EDIT: It's actually installing as expected with |
This has been happening to me as well for months now. We have an internal plug we publish and use for all of our repositories. |
I have the same issue as @nickzelei -- shared company config -- that suddenly started being unable to find |
I had a similar problem with my monorepo. Moving the |
We are experiencing this as well. We have a node module which requires However, this seems to be a bug (I think) in yarn v1 as this only happens with yarn v1. This does not happen with yarn v3 anymore (I would assume it also works with yarn v2). As yarn v1 is not updated anymore (except for critical vulnerabilities), you might want to upgrade to yarn v3 (if possible for you). |
This at least should get CI passing again. There are a couple parts to this. First, the `examples/sentiment` package didn't have either a `format` or `lint` script. We add a `format` script (but don't run it), and a `lint` script that exits with 0. The code style in the `examples/sentiment` package doesn't match up with the rest of this repo, so it will have to be fixed before we add an actual `lint` script that does something useful. Another part of this is that the `lint` script for `packages/ui-extensions-sdk` broke after pulling in the code from the `apps` repo. It's unclear why, but `eslint-plugin-prettier` seems to have some issue with being in a monorepo when run under yarn v1 and not at the top-level: prettier/eslint-plugin-prettier#396. While we could upgrade to yarn v3, we hold off on making that change at the moment. Finally, we add a few ignore files so the format/lint scripts are useful in development (where there might be artifacts in the respective directories).
ESLint was broken in the CRA template for two reasons: - ESLint was unable not import `eslint-config-prettier` (dependency of `@defencedigital/eslint-config-react`) – could be to do with package hoisting not too clear why just this one specifically (is mentioned here though: prettier/eslint-plugin-prettier#396) - it was trying to lint `src/*` which would be expanded by the shell and fail if the `src/components` directory was empty (except for `.gitkeep`)
ESLint was broken in the CRA template for two reasons: - ESLint was unable not import `eslint-config-prettier` (dependency of `@defencedigital/eslint-config-react`) – could be to do with package hoisting not too clear why just this one specifically (is mentioned here though: prettier/eslint-plugin-prettier#396) - it was trying to lint `src/*` which would be expanded by the shell and fail if the `src/components` directory was empty (except for `.gitkeep`)
ESLint was broken in the CRA template for two reasons: - ESLint was unable not import `eslint-config-prettier` (dependency of `@defencedigital/eslint-config-react`) – could be to do with package hoisting not too clear why just this one specifically (is mentioned here though: prettier/eslint-plugin-prettier#396) - it was trying to lint `src/*` which would be expanded by the shell and fail if the `src/components` directory was empty (except for `.gitkeep`) This fixes those and adds a step to the smoke test to test the lint command.
ESLint was broken in the CRA template for two reasons: - ESLint was unable not import `eslint-config-prettier` (dependency of `@defencedigital/eslint-config-react`) – could be to do with package hoisting not too clear why just this one specifically (is mentioned here though: prettier/eslint-plugin-prettier#396) - it was trying to lint `src/*` which would be expanded by the shell and fail if the `src/components` directory was empty (except for `.gitkeep`) This fixes both of those problems.
ESLint was broken in the CRA template for two reasons: - ESLint was unable not import `eslint-config-prettier` (dependency of `@defencedigital/eslint-config-react`) – could be to do with package hoisting not too clear why just this one specifically (is mentioned here though: prettier/eslint-plugin-prettier#396) - it was trying to lint `src/*` which would be expanded by the shell and fail if the `src/components` directory was empty (except for `.gitkeep`) This fixes both of those problems.
ESLint was broken in the CRA template for two reasons: - ESLint was unable not import `eslint-config-prettier` (dependency of `@defencedigital/eslint-config-react`) – could be to do with package hoisting not too clear why just this one specifically (is mentioned here though: prettier/eslint-plugin-prettier#396) - it was trying to lint `src/*` which would be expanded by the shell and fail if the `src/components` directory was empty (except for `.gitkeep`) This fixes both of those problems.
ESLint was broken in the CRA template for two reasons: - ESLint was unable not import `eslint-config-prettier` (dependency of `@defencedigital/eslint-config-react`) – could be to do with package hoisting not too clear why just this one specifically (is mentioned here though: prettier/eslint-plugin-prettier#396) - it was trying to lint `src/*` which would be expanded by the shell and fail if the `src/components` directory was empty (except for `.gitkeep`) This fixes both of those problems, and adds a step to the smoke test workflow to explicitly test the lint command.
ESLint was broken in the CRA template for two reasons: - ESLint was unable not import `eslint-config-prettier` (dependency of `@defencedigital/eslint-config-react`) – could be to do with package hoisting not too clear why just this one specifically (is mentioned here though: prettier/eslint-plugin-prettier#396) - it was trying to lint `src/*` which would be expanded by the shell and fail if the `src/components` directory was empty (except for `.gitkeep`) This fixes both of those problems, and adds a step to the smoke test workflow to explicitly test the lint command.
ESLint was broken in the CRA template for two reasons: - ESLint was unable not import `eslint-config-prettier` (dependency of `@defencedigital/eslint-config-react`) – could be to do with package hoisting not too clear why just this one specifically (is mentioned here though: prettier/eslint-plugin-prettier#396) - it was trying to lint `src/*` which would be expanded by the shell and fail if the `src/components` directory was empty (except for `.gitkeep`) This fixes both of those problems, and adds a step to the smoke test workflow to explicitly test the lint command.
ESLint was broken in the CRA template for two reasons: - ESLint was unable not import `eslint-config-prettier` (dependency of `@defencedigital/eslint-config-react`) – could be to do with package hoisting not too clear why just this one specifically (is mentioned here though: prettier/eslint-plugin-prettier#396) - it was trying to lint `src/*` which would be expanded by the shell and fail if the `src/components` directory was empty (except for `.gitkeep`) This fixes both of those problems, and adds a step to the smoke test workflow to explicitly test the lint command.
ESLint was broken in the CRA template for two reasons: - ESLint was unable not import `eslint-config-prettier` (dependency of `@defencedigital/eslint-config-react`) – could be to do with package hoisting not too clear why just this one specifically (is mentioned here though: prettier/eslint-plugin-prettier#396) - it was trying to lint `src/*` which would be expanded by the shell and fail if the `src/components` directory was empty (except for `.gitkeep`) This fixes both of those problems, and adds a step to the smoke test workflow to explicitly test the lint command.
Any updates with this? I can run using an npm command via package.json that calls
Here is what my files look like... package.json
.eslintrc.json
|
Running |
@baxelson12 Thanks for the response, but I already have the latest version (4.0.0) installed. Just to be sure, I uninstalled the plugin and reinstalled it using that command, but I'm still receiving the same error in VSCode. |
I've been struggling to find a fix for this one for several days already and finally made it work on my end. It seems that even if I run Try checking the After changing the values, try running If the folder exists, try running Hope this can help. |
@jamesgordo I was able to get it working the other day. I just wiped out |
I moved |
I've had the same problem with eslint@8.x.x and eslint-config-prettier@8.x.x . After downgrading
things started to work again. |
still, I can't fix the issue with these solutions |
this worked for me ,tks |
reasonSame problem in a monorepo. I have a custom eslint config dependency The root package.json has a config "workspaces": {
"packages": [
"Packages/*"
],
"nohoist": [
"**"
]
},
"devDependencies": {
"eslint-config-xxx": "1.1.1",
} So eslint-plugin-prettrier is not installed in the root resolveI found this post, following its instruction, add a dependency .eslintrc.js: require('@rushstack/eslint-patch/modern-module-resolution')
// Add your "extends" boilerplate here, for example:
module.exports = {
extends: ['xxx', 'yyy'],
rules: {
'no-magic-numbers': 'off',
complexity: 'off',
'no-return-assign': 'off',
},
} Then errors disappeared. |
I am facing the same issue for a node/typescript application, none of the solutions mentioned here solved it for me.
I had installed the latest versions of these packages but it didn't help. |
Did you find a solution for CI @okize? |
@git-ashish no, this was happening only on my mac and not on my linux dev-box, so I run this only on linux now. |
@git-ashish the only thing that worked in CI was adding |
Thanks! I'll give that a go. For th time being I used just _npm ci _ and that worked |
you need wiped out |
In my case, I'm working on monorepo with yarn workspaces with a single None of the solutions mentioned before have worked |
Deleting |
This issue seems stale, feel free to create a new one with reproduction instead. |
For me in vscode I pressed |
this one helped |
We are running into the same issue. We are using yarn 1.22 during local development and npm 6.13.17 centrally.
Tried using:
So I think this is still a problem and somehow the resolution does not work correctly. Based on the various pages and issues describing the same problem again and again with various versions - I don't think it's a problem specific to a specific version but rather a general problem in some environments on how e.g. the node_modules are loaded and organized. |
Restarting WebStorm was sufficient for me |
Im just doing this step
|
For me this error resolved when i update my node version to v18.11.0 and npm -v is 8.19.2 |
I had this same error and what resolved it for me was updating the node to version 18.20.1, the same version in which my project was developed. I suspected that the error could be due to the node version, which on the server I was trying to run build on was v12. After I updated using NVM it worked. (The OS on the server is Ubuntu 22.04 ). |
For anyone still struggling with this, I had almost the exact same scenario as @mgrsskls mentioned above: #396 (comment). Next.js v13.5, Yarn 1 workspaces, Storybook v7, and a custom shared eslint config package. Adding Storybook broke the module resolution somehow, preventing the shared eslint deps from getting hoisted up to the root level. My solution was to add the "resolutions": {
"@typescript-eslint/eslint-plugin": "^6.4.0",
"@typescript-eslint/parser": "^6.4.0",
"eslint": "^8.47.0",
"eslint-config-next": "^13.4.17",
"eslint-config-prettier": "^9.0.0",
"eslint-config-react": "^1.1.7",
"eslint-config-turbo": "^1.10.12",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-react-hooks": "^4.6.0",
"prettier": "^3.0.2"
} |
This issue occurred for me in CI. I resolved it by updating my package versions in nextjs project to:
|
What version of
eslint
are you using?"eslint": "^7.21.0",
What version of
prettier
are you using?"prettier": "^2.2.1",
What version of
eslint-plugin-prettier
are you using?"eslint-plugin-prettier": "^3.3.1"
Please paste any applicable config files that you're using (e.g.
.prettierrc
or.eslintrc
files)What did you expect to happen?
What actually happened?
normal work
devDependencies version
The text was updated successfully, but these errors were encountered: