Categories
JavaScript Answers

How to fix Babel unexpected token import when running mocha tests with JavaScript?

Spread the love

To fix Babel unexpected token import when running mocha tests with JavaScript, we add the @babel/preset-env library.

To install it, we run

npm install @babel/preset-env --save-dev

Then in the .babelrc file, we add

{
  "presets": ["@babel/preset-env"]
}

to add the Babel preset to clear the syntax error.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *