Shane Bishop
Shane Bishop

Reputation: 4750

eslint "Cannot find module 'eslint/lib/util/source-code'" error

I am trying to run eslint using yarn lint. When I run it, it fails with the following output:

shane@shanePC$ yarn lint
yarn run v1.22.17
$ eslint --ext .js --ext .jsx .

Oops! Something went wrong! :(

ESLint: 7.32.0

Error: Failed to load plugin 'import' declared in '.eslintrc.json » @deep-security/eslint-config » eslint-config-standard': Cannot find module 'eslint/lib/util/source-code'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (/home/shane/src/c1ws-tdax-ui/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object. (/home/shane/src/c1ws-tdax-ui/node_modules/eslint-plugin-import/lib/ExportMap.js:20:19)
    at Module._compile (/home/shane/src/c1ws-tdax-ui/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

I assume the problem is with my package.json, so here it is (proprietary information has been redacted):

{
  "name": "<redacted>",
  "version": "1.0.0",
  "private": true,
  "main": "index.js",
  "repository": "<redacted>",
  "license": "SEE LICENSE IN LICENSE",
  "publishConfig": {
    "registry": "<redacted>"
  },
  "devDependencies": {
    "<redacted>": "<redacted>",
    "react-scripts": "^4.0.3"
  },
  "dependencies": {
    "<redacted>": "<redacted>",
    "react": "^16.8.6",
    "react-dom": "^16.8.6",
    "react-intl": "^5.21.0",
    "react-redux": "^7.2.6"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom --watchAll=false",
    "eject": "react-scripts eject",
    "lint": "eslint --ext .js --ext .jsx ."
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

In case it is relevant, here is my .eslintrc.json as well:

{
  "extends": [
    "<redacted>",
    "<redacted>"
  ],
  "env": {
    "jest": true
  },
  "rules": {
    "import/no-named-default": "off"
  },
  "parser": "babel-eslint"
}

I am running node 10.19.0 and yarn 1.22.17. My OS is Linux Ubuntu 20.04.

How can I fix my setup so that yarn lint will successfully run eslint on my project?

Upvotes: 2

Views: 4379

Answers (1)

Chris Josh
Chris Josh

Reputation: 475

in your package.json, try:

"lint": "eslint --ext .js,.jsx ."

Upvotes: -1

Related Questions