RangerMing
2021-03-02 15:46
采纳率: 100%
浏览 1.1k

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"
	]
}
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • Nacl.Zz 2021-03-03 10:05
    已采纳

    尝试在.eslintrc中添加

    "parser": "@babel/eslint-parser", 
    "parserOptions": { "requireConfigFile" : "false" }
    已采纳该答案
    打赏 评论
  • ethan_86 2021-09-27 09:26

    我的环境

    
      "dependencies": {
        "ant-design-vue": "^2.2.8",
        "core-js": "^3.8.3",
        "register-service-worker": "^1.7.2",
        "vue": "^3.2.6",
        "vue-router": "^4.0.3",
        "vuex": "^4.0.0"
      },
      "devDependencies": {
        "@babel/core": "^7.12.16",
        "@babel/eslint-parser": "^7.12.16",
        "@vue/cli-plugin-babel": "~5.0.0-beta.4",
        "@vue/cli-plugin-eslint": "~5.0.0-beta.4",
        "@vue/cli-plugin-pwa": "~5.0.0-beta.4",
        "@vue/cli-plugin-router": "~5.0.0-beta.4",
        "@vue/cli-plugin-vuex": "~5.0.0-beta.4",
        "@vue/cli-service": "~5.0.0-beta.4",
        "@vue/compiler-sfc": "^3.2.6",
        "@vue/eslint-config-prettier": "^6.0.0",
        "babel-plugin-import": "^1.13.3",
        "eslint": "^7.20.0",
        "eslint-plugin-prettier": "^3.3.1",
        "eslint-plugin-vue": "^7.2.0",
        "less": "^4.1.1",
        "less-loader": "^10.0.1",
        "prettier": "^2.2.1"
      }
    
    打赏 评论

相关推荐 更多相似问题