nuffyhaha
RangerMing
采纳率100%
2021-03-02 15:46

vue文件提示: No Babel config file detected

使用`vue-cli`创建的项目中,vue文件第一行有波浪线提示,虽然项目能正常运行,但看着难受,希望能获取到解决办法。

不要那种忽略 Eslint 提示的答案

提示内容:

Parsing error: No Babel config file detected for C:\Users\XXXX\About.vue. Either disable config file checking with requireConfigFile: false, or configure Babel so that it can find the config files.eslint

vue-cli 版本:@vue/cli 5.0.0-alpha.5

vue 版本:vue@3.0.6

node 版本:v15.3.0

babel.config.js

module.exports = {
    presets: ["@vue/cli-plugin-babel/preset"],
};

.editorconfig


# EditorConfig is awesome: http://EditorConfig.org
 
# 是否是顶级配置文件,设置为true的时候才会停止搜索.editorconfig文件
root = true
 
# Unix-style newlines with a newline ending every file
[*]
# 换行符类型格式,一般用lf
end_of_line = lf
# 末尾行后加多一行空行
insert_final_newline = true
 
# 4 space indentation
[*.vue]
# 缩进类型
indent_style = tab
# 缩进数量
# indent_size = 4
 
# Tab indentation (no size specified)
[*.js]
indent_style = tab

[*.scss]
indent_style = tab
 
# Indentation override for all JS under lib directory
[lib/**.js]
indent_style = tab
 
# Matches the exact files either package.json or .travis.yml
[{package.json,.travis.yml}]
indent_style = tab

package.json

{
	"name": "hellovue",
	"version": "0.1.0",
	"private": true,
	"scripts": {
		"serve": "vue-cli-service serve",
		"build": "vue-cli-service build",
		"lint": "vue-cli-service lint"
	},
	"dependencies": {
		"core-js": "^3.8.3",
		"vue": "^2.6.11",
		"vue-router": "^3.5.1",
		"vuex": "^3.6.2"
	},
	"devDependencies": {
		"@babel/core": "^7.12.16",
		"@babel/eslint-parser": "^7.12.16",
		"@vue/cli-plugin-babel": "~5.0.0-alpha.5",
		"@vue/cli-plugin-eslint": "~5.0.0-alpha.5",
		"@vue/cli-plugin-router": "~5.0.0-alpha.5",
		"@vue/cli-plugin-vuex": "~5.0.0-alpha.5",
		"@vue/cli-service": "~5.0.0-alpha.5",
		"@vue/eslint-config-prettier": "^6.0.0",
		"eslint": "^7.20.0",
		"eslint-plugin-prettier": "^3.3.1",
		"eslint-plugin-vue": "^7.6.0",
		"prettier": "^2.2.1",
		"sass": "^1.32.7",
		"sass-loader": "^11.0.1",
		"vue-template-compiler": "^2.6.11"
	},
	"eslintConfig": {
		"root": true,
		"env": {
			"node": true
		},
		"extends": [
			"plugin:vue/essential",
			"eslint:recommended",
			"@vue/prettier"
		],
		"parserOptions": {
			"parser": "@babel/eslint-parser"
		},
		"rules": {}
	},
	"browserslist": [
		"> 1%",
		"last 2 versions",
		"not dead"
	]
}
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • z1259678404 Nacl.Zz 1月前

    尝试在.eslintrc中添加

    "parser": "@babel/eslint-parser", 
    "parserOptions": { "requireConfigFile" : "false" }
    点赞 评论 复制链接分享