richardb
0
Q:

cannot use import statement outside a module

# there are a lot of possible solutions for this problem

1) change es6 to es5 import
import package from 'packageName'; -> 
var package = require('packageName');

2) change file extension (.js -> .mjs)

3) add "type: module" in package.json

4) add 'type="module"' in script tag
1
// Fix 1
Change .js files to .mjs
// Fix 2
Add "type": "module" to package.json
0

New to Communities?

Join the community