9

I am developing a chrome extension.

One of my js files contains a const object.

I tried to import this from another js file in the same directory.

Uncaught SyntaxError: Cannot use import statement outside a module

In my attributes.js

export const key_attributes = {
    'GK': ['Aerial', 'Agility', 'Handling', 'Reflexes'],
}

I have the above

In table.js, I have

import { key_attributes } from './attributes'

This gives me

Uncaught SyntaxError: Cannot use import statement outside a module`

Any help?

kyun
  • 9,710
  • 9
  • 31
  • 66
Dawn17
  • 7,825
  • 16
  • 57
  • 118
  • It's telling you that `table.js` is not a module – Phil Oct 21 '19 at 05:06
  • 1
    Try `type="module"` on the ` – yqlim Oct 21 '19 at 05:09
  • I have tried that it is working at my end, Could you please close and restart your editor, or If your using npm packages, then delete the node_modules folder and try to do npm install again, may be it is not getting import statement – bajran Oct 21 '19 at 05:14

0 Answers0