wesbos / eslint-config-wesbos

No-Sweat™ Eslint and Prettier Setup - with or without VS Code
2.74k stars 419 forks source link

Failed to load parser '@babel/eslint-parser' declared in '.eslintrc » eslint-config-wesbos': #98

Closed chemicalkosek closed 2 years ago

chemicalkosek commented 3 years ago

I was getting the following error after upgrading to 2.0 (vscode) Error:

Failed to load parser '@babel/eslint-parser' declared in '.eslintrc » eslint-config-wesbos': Cannot find module '@babel/core/package.json' 
Require stack: 
- /home/maciek/Dokumenty/websites/bookingapp/admin-frontend/node_modules/@babel/eslint-parser/lib/parse.cjs
-  - /home/maciek/Dokumenty/websites/bookingapp/admin-frontend/node_modules/@babel/eslint-parser/lib/index.cjs 
- /home/maciek/Dokumenty/websites/bookingapp/admin-frontend/node_modules/@eslint/eslintrc/lib/config-array-factory.js
-  - /home/maciek/Dokumenty/websites/bookingapp/admin-frontend/node_modules/@eslint/eslintrc/lib/index.js 
- /home/maciek/Dokumenty/websites/bookingapp/admin-frontend/node_modules/eslint/lib/cli-engine/cli-engine.js 
- /home/maciek/Dokumenty/websites/bookingapp/admin-frontend/node_modules/eslint/lib/cli-engine/index.js - /home/maciek/Dokumenty/websites/bookingapp/admin-frontend/node_modules/eslint/lib/api.js
-  - /home/maciek/.vscode/extensions/dbaeumer.vscode-eslint-2.1.25/server/out/eslintServer.js

I have fixed it by doing

npm install --save-dev @babel/core

Not sure if it's an issue with eslint-config-webos or something on my side.

wesbos commented 3 years ago

Hey thanks for reporting this.

You were using the plain JS version, correct? What type of project was it?

chemicalkosek commented 3 years ago

Yes, plain JS, I've being using your config from the day it was released. It's a Nextjs project (initially based on your Advanced React course years ago) .eslintrc:

{
  "extends": ["wesbos"],
  "plugins": ["simple-import-sort"],
  "rules": {
    "react/no-multi-comp": "off",
    "react/state-in-constructor": ["off"],
    "react/jsx-props-no-spreading": "off",
    "simple-import-sort/imports": "error",
    "simple-import-sort/exports": "error",
    "arrow-parens": ["error", "as-needed"]
  }
}

.prettierrc:

{
  "arrowParens": "avoid"
}

package.json:

  "dependencies": {
    "@ant-design/icons": "^4.6.4",
    "@apollo/client": "^3.4.10",
    "@apollo/link-error": "^2.0.0-beta.3",
    "@apollo/react-components": "^4.0.0",
    "@apollo/react-ssr": "^4.0.0",
    "@hookform/resolvers": "^2.8.0",
    "@next/bundle-analyzer": "^11.1.2",
    "@nivo/core": "^0.73.0",
    "@nivo/line": "^0.73.0",
    "@zeit/next-less": "^1.0.1",
    "antd": "^4.16.13",
    "babel-plugin-import": "^1.13.3",
    "babel-plugin-styled-components": "^1.13.2",
    "dayjs": "^1.10.6",
    "graphql": "^15.5.3",
    "less": "^4.1.1",
    "less-vars-to-js": "1.3.0",
    "next": "^11.1.2",
    "next-with-apollo": "^5.2.1",
    "nprogress": "^0.2.0",
    "null-loader": "^4.0.1",
    "prop-types": "^15.7.2",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-hook-form": "^7.15.2",
    "react-responsive": "^8.2.0",
    "styled-components": "^5.3.1",
    "yup": "^0.32.9"
  },
  "license": "MIT",
  "devDependencies": {
    "@babel/eslint-parser": "^7.15.4",
    "@babel/preset-react": "^7.14.5",
    "@types/node": "^16.9.0",
    "@typescript-eslint/eslint-plugin": "^4.31.0",
    "@typescript-eslint/parser": "^4.31.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^7.32.0",
    "eslint-config-airbnb": "^18.2.1",
    "eslint-config-airbnb-typescript": "^14.0.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-config-wesbos": "^2.0.0",
    "eslint-plugin-html": "^6.1.2",
    "eslint-plugin-import": "^2.24.2",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-prettier": "^4.0.0",
    "eslint-plugin-react": "^7.25.1",
    "eslint-plugin-react-hooks": "^4.2.0",
    "eslint-plugin-simple-import-sort": "^7.0.0",
    "prettier": "^2.4.0",
    "typescript": "^4.4.2"
  }
}
wesbos commented 3 years ago

super helpful, thank you. Will have a lookski

neodaoist commented 3 years ago

Got a similar error when running npx install-peerdeps --dev eslint-config-wesbos, and was able to resolve by first running @chemicalkosek 's code snippet then retrying. Wanted to share in case helpful. Thanks chemical!

install-peerdeps v3.0.3
Installing peerdeps for eslint-config-wesbos@latest.
npm install eslint-config-wesbos@2.0.1 @types/node@^16.7.13 @typescript-eslint/eslint-plugin@^4.31.0 @typescript-eslint/parser@^4.31.0 eslint@^7.32.0 eslint-config-airbnb@^18.2.1 eslint-config-airbnb-typescript@^14.0.0 eslint-config-prettier@^8.3.0 eslint-plugin-html@^6.1.2 eslint-plugin-import@^2.24.2 eslint-plugin-jsx-a11y@^6.4.1 eslint-plugin-prettier@^4.0.0 eslint-plugin-react@^7.25.1 eslint-plugin-react-hooks@^4.2.0 prettier@^2.3.2 typescript@^4.4.2 @babel/eslint-parser@^7.15.4 @babel/preset-react@^7.14.5 --save-dev

ERR undefined
subflow commented 3 years ago

Hey,

I got the same issue on a fresh installed windows computer. Also npm install --save-dev @babel/core solved it for me.

danil0man commented 3 years ago

Hey I am getting the same errors above and is not helping image Getting this error on all my js files

danil0man commented 3 years ago

please help

wesbos commented 3 years ago

@danil0man I've already asked in this thread: https://github.com/wesbos/eslint-config-wesbos/issues/100