js-api-loader
js-api-loader copied to clipboard
SyntaxError: Unexpected token 'export'
When trying to import loader with:
import { Loader } from '@googlemaps/js-api-loader/dist/index.esm.js';
there is an error thrown when compiling the code with Sveltekit/Vite with vite build
(Use `node --trace-warnings ...` to show where the warning was created)
(node:14091) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
/Users/tonprincepro/Documents/Backup/Tripstore/Website/workspace/com.tripstorekrabi/next/node_modules/@googlemaps/js-api-loader/dist/index.esm.js:318
export { DEFAULT_ID, Loader, LoaderStatus };
^^^^^^
SyntaxError: Unexpected token 'export'
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1033:15)
at Module._compile (node:internal/modules/cjs/loader:1069:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:170:29)
at ModuleWrap.evaluate (<anonymous>)
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
[SyntaxError: Unexpected token 'export']
Environment details
- @googlemaps/js-api-loader
- macOS 12.4 (21F79)
- "@googlemaps/js-api-loader": "^1.14.3", "@sveltejs/adapter-auto": "1.0.0-next.60", "@sveltejs/kit": "1.0.0-next.375", "vite": "^3.0.0"
When adding "type": "module"
to package.json the error is gone.