【问题标题】:eslint "Cannot find module 'eslint/lib/util/source-code'" erroreslint“找不到模块'eslint/lib/util/source-code'”错误
【发布时间】:2021-12-13 22:09:15
【问题描述】:

我正在尝试使用 yarn lint 运行 eslint。当我运行它时,它会失败并显示以下输出:

shane@shanePC$ 绒线 纱线运行 v1.22.17 $ eslint --ext .js --ext .jsx 。 哎呀!有些不对劲! :( ESLint:7.32.0 错误:无法加载在 '.eslintrc.json » @deep-security/eslint-config » eslint-config-standard' 中声明的插件 'import':找不到模块 'eslint/lib/util/source-code' 在 Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) 在 Function.Module._load (internal/modules/cjs/loader.js:562:25) 在 Module.require (internal/modules/cjs/loader.js:692:17) 在需要(/home/shane/src/c1ws-tdax-ui/node_modules/v8-compile-cache/v8-compile-cache.js:159:20) 在对象。 (/home/shane/src/c1ws-tdax-ui/node_modules/eslint-plugin-import/lib/ExportMap.js:20:19) 在 Module._compile (/home/shane/src/c1ws-tdax-ui/node_modules/v8-compile-cache/v8-compile-cache.js:192:30) 在 Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) 在 Module.load (internal/modules/cjs/loader.js:653:32) 在 tryModuleLoad (internal/modules/cjs/loader.js:593:12) 在 Function.Module._load (internal/modules/cjs/loader.js:585:3) error 命令失败,退出代码为 2。 info 访问 https://yarnpkg.com/en/docs/cli/run 以获取有关此命令的文档。

我认为问题出在我的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"
    ]
  }
}

如果相关,这里也是我的.eslintrc.json

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

我正在运行节点 10.19.0 和纱线 1.22.17。我的操作系统是 Linux Ubuntu 20.04。

如何修复我的设置,以便yarn lint 能够在我的项目上成功运行 eslint?

【问题讨论】:

    标签: javascript eslint yarnpkg package.json eslintrc


    【解决方案1】:

    在你的 package.json 中,尝试:

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

    【讨论】:

    • 进行此更改时,我仍然遇到同样的错误。
    猜你喜欢
    • 2019-03-18
    • 2019-03-28
    • 2018-05-26
    • 2020-07-03
    • 2021-07-16
    • 2022-01-20
    • 2018-11-19
    • 2017-01-04
    • 2018-04-04
    相关资源
    最近更新 更多