Answer the question
In order to leave comments, you need to log in
Running eslint ./src throws an error, how to fix?
Throws an error Error: Cannot find module 'babel-eslint' with this dependency installed
Here is package
{
"name": "forwp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "webpack-dev-server --mode development --open",
"build": "webpack --mode production"
},
"author": "",
"license": "ISC",
"devDependencies": {
"autoprefixer": "^9.1.5",
"babel-core": "^6.26.3",
"babel-eslint": "^10.0.1",
"babel-loader": "^7.1.5",
"babel-preset-env": "^1.7.0",
"babel-preset-react": " ^6.24.1",
"babel-preset-stage-3": "^6.24.1",
"css-loader": "^1.0.0",
"eslint": "^5.6.1",
"eslint-config-prettier": " ^3.1.0",
"eslint-plugin-babel": "^5.2.1",
"eslint-plugin-prettier": "^3.0.0",
"extract-text-webpack-plugin": "^4.0. 0-beta.0",
"postcss-loader": "^3.0.0",
"prettier": "^1.14.3",
"style-loader": "^0.23.0",
"webpack": "^ 4.17.2",
"webpack-cli": "^3.1.0",
"webpack-dev-server": "^3.1.8"
},
"dependencies": {
"browserslist": "^4.1.1",
"node-sass": "^4.9.3",
"prop-types": "^15.6.2",
"react": "^16.5. one",
"react-dom": "^16.5.1",
"sass-loader": "^7.1.0"
},
"browserslist": [
"last 4 version",
"> 1%",
"not ie <= 9 "
]
}
Here is eslintrc
{
"extends":[
"react-app",
"prettier"
],
"rules":{
"prettier/prettier": "error",
"strict": 0
},
"parser": "babel -eslint",
"parserOptions": {
"sourceType": "module",
"allowImportExportEverywhere": false,
"codeFrame": true,
"ecmaFeatures": {
"jsx": true
}
},
"env": {
"browser": true,
"node": true
},
"plugins":[
"prettier",
"babel"
]
}
Answer the question
In order to leave comments, you need to log in
This should work
Cause, you are trying to run a global eslint module that does not know your local (installed in the project) plugins.
In order not to write such a long path every time,
add to package.json
"scripts": {
"dev": "webpack-dev-server --mode development --open",
"build": "webpack --mode production",
"eslint": "eslint"
}
npm run eslint ./src
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question