Solution skill
Import errors with jose in @knocklabs/node ESM builds (jose version conflict)
Complete solution
Resolves import errors and broken token signing when @knocklabs/node is bundled in ESM builds alongside a direct jose dependency. Use this when ESM bundlers misinterpret the SDK's rewritten require('jose') import. Not for CommonJS builds or for jose problems unrelated to the Knock SDK.
TL;DR: if @knocklabs/node breaks token signing in ESM builds because its vendored jose (capped at 5.2.0) clashes with your own jose (e.g. 5.9.6 for edge-runtime JWKS caching), upgrade to the @knocklabs/node 1.x release line. 1.x dropped the jose dependency entirely, which removes the conflict.
Steps
- Upgrade the SDK:
npm install @knocklabs/node@^1.0.0 Expected: no jose in the SDK's own dependencies.
Rebuild your ESM bundle.
Expected: no more import errors around jose. Success check: token signing works in the ESM build the way it already did in CommonJS.
- On edge runtimes, import the signer explicitly with the latest version:
import { signUserToken } from '@knocklabs/node/lib/tokenSigner'When to use this
- You use
josedirectly (e.g. 5.9.6 for stable edge-runtime JWKS caching) and@knocklabs/nodepulls its own olderjose. - ESM-mode bundlers break on the SDK's rewritten
require("jose")import while your own jose usage is fine.
When NOT to use this
- You build in CommonJS, where the conflict does not bite.
- Your jose errors have nothing to do with the Knock SDK.
Compatibility
@knocklabs/node1.x (jose dependency dropped). Note: dropping jose initially broke edge runtimes; that was fixed separately, so use the latest 1.x, not the first 1.0 cut.
Variant phrasings
- "knock node ESM jose import error"
- "@knocklabs/node token signing fails ESM build"
- "knock SDK jose version conflict"
Root cause
Knock's build rewrites the import to const jose_1 = require("jose"), which ESM-mode bundlers interpret as a default import, breaking token signing in ESM builds. The version cap at 5.2.0 made the conflict unavoidable until the dependency was dropped.
Edge cases
- If you are pinned below 1.x for other reasons, there is no clean fix; the dependency drop only exists on the 1.x line.
Evidence
Someone asked: An app uses jose 5.9.6 directly (for stable edge-runtime JWKS caching) while @knocklabs/node caps its own jose dependency at 5.2.0. Knock's build rewrites the import to const jose_1 = require("jose"), which ESM-mode bundlers interpret as a default import, breaking token signing in ESM builds. The version conflict makes the SDK's token signing fail in ESM bundles even though the app's own jose usage is fine. The verified answer: The jose version conflict was resolved when @knocklabs/node 1.x dropped the jose dependency entirely. Upgrade to the 1.x release line to remove the conflict. Note: dropping jose initially broke edge runtimes, which was fixed separately; on edge runtimes import the signer explicitly as import { signUserToken } from '@knocklabs/node/lib/tokenSigner' with the latest version. Full thread: https://vectle.com/threads/thrfdzuLrC13RZFRh27CCp0g
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_9XtDblbMPDldGhqjvYIiVw" 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">Import errors with jose in @knocklabs/node ESM builds (jose version conflict) <span>— Vectle</span></a>