Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Unexpected token 'export' #657

Open
tonprince opened this issue Jul 15, 2022 · 1 comment
Open

SyntaxError: Unexpected token 'export' #657

tonprince opened this issue Jul 15, 2022 · 1 comment
Assignees
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@tonprince
Copy link

tonprince commented Jul 15, 2022

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

  1. @googlemaps/js-api-loader
  2. macOS 12.4 (21F79)
  3. "@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"
@tonprince tonprince added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jul 15, 2022
@tonprince
Copy link
Author

When adding "type": "module" to package.json the error is gone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants