简体   繁体   English

eslint“找不到模块'eslint/lib/util/source-code'”错误

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

I am trying to run eslint using yarn lint .我正在尝试使用yarn lint运行 eslint 。 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):我认为问题出在我的package.json ,所以在这里(专有信息已被编辑):

{
  "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:如果相关,这里也是我的.eslintrc.json

{
  "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.我正在运行节点 10.19.0 和纱线 1.22.17。 My OS is Linux Ubuntu 20.04.我的操作系统是 Linux Ubuntu 20.04。

How can I fix my setup so that yarn lint will successfully run eslint on my project?如何修复我的设置,以便yarn lint能够在我的项目上成功运行 eslint?

in your package.json, try:在你的 package.json 中,尝试:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:在 VUEJS(ESLINT)中找不到模块“babel-code-frame” - Error: Cannot find module 'babel-code-frame' in VUEJS ( ESLINT) Javascript Eslint 错误:找不到模块“optionator” - Javascript Eslint Error: Cannot find module 'optionator' Mac WebStorm错误:无法找到模块'eslint-config-airbnb' - Mac WebStorm Error: Cannot find module 'eslint-config-airbnb' 尝试创建提交时出现错误“找不到模块&#39;eslint-config-strict / es5&#39;” - Error “Cannot find module 'eslint-config-strict/es5'” when I try to create a commit Visual Studio 2015 Update 3 eslint找不到模块eslint-plugin-react - Visual studio 2015 update 3 eslint Cannot find module eslint-plugin-react 在 Typescript 和 Eslint 中使用别名时找不到模块 - cannot find module when using alias with Typescript and Eslint ESLint 8.31.0“错误:无法加载在‘.eslintrc.js » eslint-config-standard’中声明的插件‘import’:找不到模块‘array.prototype.flatmap’” - ESLint 8.31.0 "Error: Failed to load plugin 'import' declared in '.eslintrc.js » eslint-config-standard': Cannot find module 'array.prototype.flatmap" 如何解决,craco: *** Cannot find ESLint loader (eslint-loader)。 *** ANTd 和 React 错误 (2021) - How to solve, craco: *** Cannot find ESLint loader (eslint-loader). *** error with ANTd and React (2021) 执行 eslint 时找不到模块“json-schema”错误 - Can not find module “json-schema” error when executing eslint 在 WebStorm ESLint 中获取 ESLint 错误:解析导入模块中的错误 - Getting ESLint error in WebStorm ESLint: Parse errors in imported module
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM