eslint-plugin-prettier: Failed to load plugin 'prettier' declared in '.eslintrc.js': Cannot find module 'eslint-plugin-prettier'
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)
module.exports = {
root: true,
env: {
browser: true,
es6: true,
node: true,
},
extends: [ "plugin:prettier/recommended" ],
parserOptions: {
parser: "babel-eslint",
ecmaVersion: 12,
sourceType: "module"
},
rules: {
"no-console": 0
},
globals: {
getApp: false,
Page: false,
wx: false,
App: false,
getCurrentPages: false,
Component: false
}
}
What did you expect to happen?
[Error]
Failed to load plugin 'prettier' declared in '.eslintrc.js': Cannot find module 'eslint-plugin-prettier'
Require stack:
- /Users/xxx/Documents/xxxx/xxxx/__placeholder__.js
Referenced from: /Users/xxx/Documents/xxxx/xxxxx/.eslintrc.js
Happened while validating /Users/xxxxx/Documents/xxxxx/xxxxx/xxxxx.js
This can happen for a couple of reasons:
1. The plugin name is spelled incorrectly in an ESLint configuration file (e.g. .eslintrc).
2. If ESLint is installed globally, then make sure 'eslint-plugin-prettier' is installed globally as well.
3. If ESLint is installed locally, then 'eslint-plugin-prettier' isn't installed correctly.
Consider running eslint --debug /Users/xxxxx/Documents/xxxxx/xxxxx/xxxxx.js from a terminal to obtain a trace about the configuration files used.
What actually happened? normal work
devDependencies version
"devDependencies": {
"autoprefixer": "^9.7.3",
"babel-eslint": "^10.1.0",
"del": "^6.0.0",
"eslint": "^7.21.0",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-prettier": "^3.3.1",
"gulp": "^4.0.2",
"gulp-imagemin": "^7.1.0",
"gulp-notify": "^3.2.0",
"gulp-plumber": "^1.2.1",
"gulp-postcss": "^9.0.0",
"gulp-rename": "^2.0.0",
"gulp-replace": "^1.0.0",
"gulp-sass": "^4.1.0",
"gulp-tap": "^2.0.0",
"miniprogram-automator": "^0.10.0",
"path": "^0.12.7",
"postcss": "^8.2.1",
"prettier": "^2.2.1",
"yargs": "^16.2.0"
}
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 40
- Comments: 37 (3 by maintainers)
Commits related to this issue
- UIAPPS-78 Fix `format`, `lint`, and `test` scripts 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` ... — committed to DataDog/apps by joneshf-dd 3 years ago
- fix(CRATemplate): Fix 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`... — committed to Royal-Navy/design-system by jpveooys 3 years ago
- fix(CRATemplate): Fix 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`... — committed to Royal-Navy/design-system by jpveooys 3 years ago
- fix(CRATemplate): Fix 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`... — committed to Royal-Navy/design-system by jpveooys 3 years ago
- fix(CRATemplate): Fix 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`... — committed to Royal-Navy/design-system by jpveooys 3 years ago
- fix(CRATemplate): Fix 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`... — committed to Royal-Navy/design-system by jpveooys 3 years ago
- fix(CRATemplate): Fix 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`... — committed to Royal-Navy/design-system by jpveooys 3 years ago
- fix(CRATemplate): Fix 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`... — committed to Royal-Navy/design-system by jpveooys 3 years ago
- fix(CRATemplate): Fix 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`... — committed to Royal-Navy/design-system by jpveooys 3 years ago
- fix(CRATemplate): Fix 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`... — committed to Royal-Navy/design-system by jpveooys 3 years ago
- fix(CRATemplate): Fix 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`... — committed to Royal-Navy/design-system by jpveooys 3 years ago
- fix(CRATemplate): Fix 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`... — committed to Royal-Navy/design-system by jpveooys 3 years ago
Running
npm i eslint-plugin-prettier@latest -D
solved this for me.@jamesgordo I was able to get it working the other day. I just wiped out
node_modules
and did a freshnpm i
. It still wasn’t working, but after I restarted VSCode, it did 🤷For me in vscode I pressed
F1
then typedreload window
and the error was gone.still, I can’t fix the issue with these solutions
I have the same issue as @nickzelei – shared company config – that suddenly started being unable to find
eslint-plugin-prettier
. This only happens in CI, not in local dev environment.I moved
eslint-plugin-prettier
from dev dependencies into dependencies, and it works now.We are experiencing this as well. We have a node module which requires
eslint-plugin-prettier
as a dependency and in all our projects it installseslint-plugin-prettier
directly innode_modules
(in that case everything works fine), but in one project it installs it innode_modules/OUR_NODE_MODULE/node_modules
(in this case it doesn’t work). In both cases, our node module is the only one which requireseslint-plugin-prettier
,yarn why eslint-plugin-prettier
also outputs the same information (only our node module). I figured out that installing https://www.npmjs.com/package/@nuxtjs/storybook causeseslint-plugin-prettier
to be installednode_modules/OUR_NODE_MODULE/node_modules
, but it is still the onlyeslint-plugin-prettier
being installed and I have no clue why@nuxtjs/storybook
would cause that.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).
I’ve had the same problem with eslint@8.x.x and eslint-config-prettier@8.x.x . After downgrading
npm i -D eslint@^7 eslint-config-prettier@^7
things started to work again.
Restarting WebStorm was sufficient for me
We are running into the same issue. We are using yarn 1.22 during local development and npm 6.13.17 centrally. We are experiencing this issue “Failed to load plugin ‘<name>’ declared in ‘.eslintrc’: Cannot find module '<eslint-plugin-name>” for multiple plug-ins:
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.
I had a similar problem with my monorepo. Moving the
eslint-plugin-prettier
andprettier
dependencies from a subproject to the yarn workspace dependencies did the trick.Deleting
node_modules
, reopening the VS Code and runningyarn install
helped me.you need wiped out
node_modules
.cache
. I am facing the same issue.@git-ashish the only thing that worked in CI was adding
eslint-plugin-prettier
as a top-level dependency inpackage.json
, even though it shouldn’t need to be added as it’s already a dependency of our organization’s eslint-config package,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
npm install
ornpm i eslint-plugin-prettier@latest -D
, theeslint-plugin-prettier
folder is not created in thenode_modules
directory. Based from my observation, somedev dependency
packages are not installed ifNODE_ENV=production
Try checking the
NODE_ENV
value of your machine by runningecho $NODE_ENV
. if the current value isproduction
try changing the values todevelopment
by runningexport NODE_ENV=development
.After changing the values, try running
npm install
again and check if the plugin is installed and folder exists:ls -lah node_modules/eslint-plugin-prettier
If the folder exists, try running
npm run build
if it works.Hope this can help.
For me this error resolved when i update my node version to v18.11.0 and npm -v is 8.19.2
Thanks! I’ll give that a go. For th time being I used just _npm ci _ and that worked
@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.
Did you find a solution for CI @okize?
@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.