Parsing error: No Babel config file detected

Viewed 9086

I'm trying to create a project in 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. Have tried running npm audit fix --force but unfortunately the result is the same. Anyone know what it could be?

3 Answers

I had the same issue and this change fixed the issue. In your .eslintrc.js file, add 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

The most important:babel.config.js should in your root directory. 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.

Solution 2

open the .eslintrc.js, and alter the root value like:

root:'',

In your terminal, run npm install. Then, replace your babel.config.js contents with below:

  "presets": [
    "@vue/cli-plugin-babel/preset"
  ]
}
Related