![](/img/trans.png)
[英]Getting `Cannot find module '.next\server\pages-manifest.json'` error when trying to add `babel.config.js` in nextjs app
[英]Lint Parsing error: Cannot find module 'babel.config.js'
我正在更新 web 應用程序的反應版本(16 到 17.0.2),我也必須更新一些依賴項。
目前,我的應用程序正在編譯和運行,但是,當我運行eslint時,它會中斷並顯示以下消息:
error Parsing error: Cannot find module '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"
有沒有人已經通過並解決了它? 謝謝!
但是我找不到這個問題的答案,我找到了一個解決方法:
您可以在 .eslintrc 主體上添加 babel 配置並指示它不要查找 babel.config 文件,例如:
您應該在 babelOptions 中添加配置。
"parser": "@babel/eslint-parser",
"parserOptions": {
"requireConfigFile": false, //Add this line
"babelOptions": {
// "configFile": "babel.config.js" //When linting it only works with absolute path
// Here starts the configuration
"presets": [
"@babel/preset-env",
"@babel/preset-react",
"react-app"
],
"plugins": ["@babel/plugin-syntax-class-properties","@babel/plugin-proposal-class-properties"]
// Here ends the configuration
}
},
這不是理想的解決方案,但它確實有效!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.