Immutable solution version
Unable to get @axiomhq/js working in Vite: SyntaxError: Unexpected token 'export'
Complete solution
Shows how to fix unable to get @axiomhq/js working in Vite: SyntaxError: Unexpected token 'export'. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Fixed upstream in axiom-js PR #56 (switched to named exports) with follow-up build fixes in PR #63: upgrade @axiomhq/js past 0.1.2/0.1.3 and the import resolves. The setup code was otherwise unchanged from the working axiom-node version.
Steps
- Migrating from @axiomhq/axiom-node to @axiomhq/js in a SvelteKit/Vite app. On SSR module evaluation,
import { Axiom } from '@axiomhq/js'fails with: SyntaxError: Unexpected token 'export', pointing at dist/esm/index.js line 1 (export * from './client';). The setup code was otherwise unchanged from the working axiom-node version. - The package's ESM build used
export *re-exports that Vite's SSR module runner could not parse. Fixed upstream in axiom-js PR #56 (switched to named exports) with follow-up build fixes in PR #63: upgrade @axiomhq/js past 0.1.2/0.1.3 and the import resolves. The maintainer confirmed the fix and closed the issue.
Expected: The maintainer confirmed the fix and closed the issue.
When to use
You are seeing this: Migrating from @axiomhq/axiom-node to @axiomhq/js in a SvelteKit/Vite app. Use this skill when you run into "Unable to get @axiomhq/js working in Vite: SyntaxError: Unexpected token 'export'".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
Versions mentioned in the source: past 0.1.2, 0.1.2 0.1.3. If you are on something much newer or older, the details may have shifted.
Why this happens
Migrating from @axiomhq/axiom-node to @axiomhq/js in a SvelteKit/Vite app.
Evidence
In the thread Unable to get @axiomhq/js working in Vite: SyntaxError: Unexpected token 'export', the question was: Migrating from @axiomhq/axiom-node to @axiomhq/js in a SvelteKit/Vite app. On SSR module evaluation, import { Axiom } from '@axiomhq/js' fails with: SyntaxError: Unexpected token 'export', pointing at dist/esm/index.js line 1 (export * from './client';). The setup code was otherwise unchanged from the working axiom-node version. The verified resolution: The package's ESM build used export * re-exports that Vite's SSR module runner could not parse. Fixed upstream in axiom-js PR #56 (switched to named exports) with follow-up build fixes in PR #63: upgrade @axiomhq/js past 0.1.2/0.1.3 and the import resolves. The maintainer confirmed the fix and closed the issue. Original discussion: https://vectle.com/threads/thr3v9l9UQ7idGgxInR50R0w
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_U-r8FdTikCCel0Dj21NfJQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Unable to get @axiomhq/js working in Vite: SyntaxError: Unexpected token 'export' <span>— Vectle</span></a>