皮棉解析错误:找不到模块' babel.config.js'
我正在更新Web应用程序的React版本(16至17.0.2),也必须更新一些依赖项。
当前,我的应用程序正在编译和运行,但是,当我运行 eslint 时,它会随以下消息打破:
错误解析错误:找不到模块'babel.config.js'
我的 .eslintrc 的配置为:
...
"parser": "@babel/eslint-parser",
"parserOptions": {
"babelOptions": {
"configFile": "babel.config.js"
}
},
...
我的 babel.config.js 是:
module.exports = {
presets: [
"@babel/preset-env",
"@babel/preset-react",
"react-app"
],
plugins: ["@babel/plugin-syntax-class-properties","@babel/plugin-proposal-class-properties"]
};
某些依赖关系是:
"@babel/core": "^7.17.9",
"@babel/eslint-parser": "^7.17.0",
"babel-eslint": "10.0.3",
"eslint": "7.5.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-config-angular": "^0.5.0",
"eslint-config-react-app": "^5.1.0",
"eslint-import-resolver-babel-module": "^5.1.0",
"eslint-import-resolver-webpack": "^0.12.2",
"eslint-loader": "4.0.2",
"eslint-plugin-angular": "^4.0.1",
"eslint-plugin-flowtype": "5.2.0",
"eslint-plugin-import": "2.22.0",
"eslint-plugin-jsx-a11y": "6.3.1",
"eslint-plugin-react": "7.20.3",
"eslint-plugin-react-hooks": "^4.0.8",
"eslint-webpack-plugin": "^3.1.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-scripts": "3.4.4",
"terser-webpack-plugin": "2.2.1",
"ts-pnp": "1.1.5",
"url-loader": "2.3.0",
"webpack": "4.41.2",
"webpack-dev-server": "3.9.0",
"webpack-manifest-plugin": "2.2.0",
"workbox-webpack-plugin": "4.3.1"
有人经历过并解决了它吗? 谢谢!
I am updating the react version (16 to 17.0.2) of a web application and I had to update some dependencies too.
Currently, my application is compiling and running however, when I run the eslint it breaks with the following message:
error Parsing error: Cannot find module 'babel.config.js'
My .eslintrc is configured like:
...
"parser": "@babel/eslint-parser",
"parserOptions": {
"babelOptions": {
"configFile": "babel.config.js"
}
},
...
My babel.config.js is:
module.exports = {
presets: [
"@babel/preset-env",
"@babel/preset-react",
"react-app"
],
plugins: ["@babel/plugin-syntax-class-properties","@babel/plugin-proposal-class-properties"]
};
Some dependencies are:
"@babel/core": "^7.17.9",
"@babel/eslint-parser": "^7.17.0",
"babel-eslint": "10.0.3",
"eslint": "7.5.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-config-angular": "^0.5.0",
"eslint-config-react-app": "^5.1.0",
"eslint-import-resolver-babel-module": "^5.1.0",
"eslint-import-resolver-webpack": "^0.12.2",
"eslint-loader": "4.0.2",
"eslint-plugin-angular": "^4.0.1",
"eslint-plugin-flowtype": "5.2.0",
"eslint-plugin-import": "2.22.0",
"eslint-plugin-jsx-a11y": "6.3.1",
"eslint-plugin-react": "7.20.3",
"eslint-plugin-react-hooks": "^4.0.8",
"eslint-webpack-plugin": "^3.1.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-scripts": "3.4.4",
"terser-webpack-plugin": "2.2.1",
"ts-pnp": "1.1.5",
"url-loader": "2.3.0",
"webpack": "4.41.2",
"webpack-dev-server": "3.9.0",
"webpack-manifest-plugin": "2.2.0",
"workbox-webpack-plugin": "4.3.1"
Does anyone have been through and solved it?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
但是,我找不到这个问题的答案,我找到了解决方法:
您可以在.eslintrc主体上添加Babel配置,并指示它不要查找babel.config文件,例如:
您应该在babeloptions中添加config 。
It is not the ideal solution, but it works!
I couldn't find an answer to this question however, I found a workaround:
You can add the babel configuration on the .eslintrc body and instruct it to not look for the babel.config file, like:
You should add the config inside babelOptions.
It is not the ideal solution, but it works!