eslint“找不到模块'eslint/lib/util/source-code'”错误
Posted
技术标签:
【中文标题】eslint“找不到模块\'eslint/lib/util/source-code\'”错误【英文标题】:eslint "Cannot find module 'eslint/lib/util/source-code'" erroreslint“找不到模块'eslint/lib/util/source-code'”错误 【发布时间】:2021-12-13 22:09:15 【问题描述】:我正在尝试使用 yarn lint
运行 eslint。当我运行它时,它会失败并显示以下输出:
我认为问题出在我的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?
【问题讨论】:
【参考方案1】:在你的 package.json 中,尝试:
"lint": "eslint --ext .js,.jsx."
【讨论】:
进行此更改时,我仍然遇到同样的错误。以上是关于eslint“找不到模块'eslint/lib/util/source-code'”错误的主要内容,如果未能解决你的问题,请参考以下文章
【Eslint配置】 eslint-config-* 和 eslint-plugin-* 的区别