[英]Parsing error: No Babel config file detected
I'm trying to create a project in vue.我正在尝试在 vue 中创建一个项目。 But I get this problem after I create a project.
但是我在创建项目后遇到了这个问题。
Parsing error: No Babel config file detected for C:\\HotelManagmet\clienthotel\babel.config.js. Either disable config file checking with requireConfigFile: false, or configure Babel so that it can find the config files.
I can not solve it, I have tried to reinstall node.js and visual studio code but the problem remains.我无法解决它,我尝试重新安装 node.js 和 Visual Studio 代码,但问题仍然存在。 Have tried running npm audit fix --force but unfortunately the result is the same.
试过运行 npm audit fix --force 但不幸的是结果是一样的。 Anyone know what it could be?
有谁知道它可能是什么?
I had the same issue and this change fixed the issue.我有同样的问题,这个改变解决了这个问题。 In your
.eslintrc.js
file, add requireConfigFile: false
在您的
.eslintrc.js
文件中,添加requireConfigFile: false
parserOptions: {
parser: '@babel/eslint-parser',
requireConfigFile: false, // <== ADD THIS
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module' // Allows for the use of imports
}
Solution 1解决方案 1
The most important: babel.config.js should in your root directory.最重要的: babel.config.js应该在你的根目录下。 it's means if you have such structure: enter image description here
这意味着如果您有这样的结构:在此处输入图像描述
root directory
--your project1
|
|--src
|--nodemodules
|--babel.config.js
--your project2
|
|--src
|--nodemodules
|--babel.config.js
if you run the project,it would show the error.如果你运行项目,它会显示错误。 so if you want to run the project1 or project2,just open it,and then make sure it as root directory.
所以如果你想运行项目1或项目2,只需打开它,然后确保它是根目录。
Solution 2解决方案 2
open the .eslintrc.js, and alter the root value like:打开 .eslintrc.js,然后更改根值,如:
root:'',
In your terminal, run npm install
.在您的终端中,运行
npm install
。 Then, replace your babel.config.js
contents with below:然后,将您的
babel.config.js
内容替换为以下内容:
"presets": [
"@vue/cli-plugin-babel/preset"
]
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.