-1

Node Version 8.6.0

npm version 5.3.0

Chrome Error ( Version 61.0.3163.100 )

Uncaught SyntaxError: Unexpected token import

Mozila Error ( Version 56.0 (64-bit) )

SyntaxError: import declarations may only appear at top level of a module import one from "./two";

Heartbeat
  • 142
  • 9
  • 1
    Debug output not a valid question – GavinBrelstaff Sep 27 '17 at 12:18
  • Possible duplicate of [In webpack how do I fix 'import declarations may only appear at top level of a module'?](https://stackoverflow.com/questions/37023369/in-webpack-how-do-i-fix-import-declarations-may-only-appear-at-top-level-of-a-m) – Maraboc Sep 27 '17 at 12:19

1 Answers1

0

import is an ES6 feature. To use ES6 features you need to install babel. Babel is a transpiler, which translates ES6 to ES5 for the browser to understand.

Run the following command:

npm install --save-dev babel-preset-es2015

add following to your .babelrc file:

{
  "presets": ["es2015"]
}
Laksh Goel
  • 169
  • 1
  • 12
  • trying adding babel config in your package.json like this: "babel": { // my babel config here } Or you can create .babelrc file in the root directory of your project – Laksh Goel Sep 27 '17 at 13:14