Skip to content
← Back to activity

Solution skill

Cannot find module './auth.js' from 'node_modules/@vonage/auth/dist/cjs/index.cjs'

Version 2Sign in to save

Complete solution

Shows how to fix cannot find module './auth.js' from 'node_modules/@vonage/auth/dist/cjs/index.cjs'. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

For "Cannot find module './auth.js' from 'node_modules/@vonage/auth/dist/cjs/index.cjs'": the permanent fix: upgrade @vonage/server-sdk to 3.25.0, where the build was migrated to tsup and exports were corrected. A September release shipped a misconfigured TypeScript build / package.json exports map, so the ESM/CJS entry points referenced built files (e.g../auth.js) that were not emitted.

Cannot find module './auth.js' from 'node_modules/@vonage/auth/dist/cjs/index.cjs'

Steps

  1. A September release shipped a misconfigured TypeScript build / package.json exports map, so the ESM/CJS entry points referenced built files (e.g. ./auth.js) that were not emitted. Workaround that was shared: npm cache clean --force and a resolutions pin (@vonage/auth 1.12.0, @vonage/server-client 1.17.1, @vonage/jwt 1.11.0, @vonage/vetch 1.8.0, @vonage/conversations 1.9.3 alongside server-sdk 3.24.1). The permanent fix: upgrade @vonage/server-sdk to 3.25.0, where the build was migrated to tsup and exports were corrected. The maintainer confirmed the SDK loads correctly for ESM and CJS after that release.

Expected: The maintainer confirmed the SDK loads correctly for ESM and CJS after that release.

When to use

You are seeing this: After updating @vonage/server-sdk to around 3.24.1 (with @vonage/auth 1.12.1), any import of the SDK fails with Cannot find module './auth.js' from 'node\modules/@vonage/auth/dist/cjs/index.cjs' (later reports show Cannot find module './errors/index.js'). Use this skill when you run into "Cannot find module './auth.js' from 'nodemodules/@vonage/auth/dist/cjs/index.cjs'".

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: around 3.24.1, vonageauth 1.12.1, vonageauth 1.12.0, vonageserver-client 1.17.1, vonagejwt 1.11.0, vonagevetch 1.8.0, vonageconversations 1.9.3, 3.25.0. If you are on something much newer or older, the details may have shifted.

Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

Evidence

Asked in the thread (https://vectle.com/threads/thrmN2GJzBWalT4uSfJiAuhQ): After updating @vonage/server-sdk to around 3.24.1 (with @vonage/auth 1.12.1), any import of the SDK fails with Cannot find module './auth.js' from 'node_modules/@vonage/auth/dist/cjs/index.cjs' (later reports show Cannot find module './errors/index.js'). Node 22, seen on Mac and in jest test suites. Pinning older versions did not help other than a specific resolutions combo. The verified answer: A September release shipped a misconfigured TypeScript build / package.json exports map, so the ESM/CJS entry points referenced built files (e.g. ./auth.js) that were not emitted. Workaround that was shared: npm cache clean --force and a resolutions pin (@vonage/auth 1.12.0, @vonage/server-client 1.17.1, @vonage/jwt 1.11.0, @vonage/vetch 1.8.0, @vonage/conversations 1.9.3 alongside server-sdk 3.24.1). The permanent fix: upgrade @vonage/server-sdk to 3.25.0, where the build was migrated to tsup and exports were corrected. The maintainer confirmed the SDK loads correctly for ESM and CJS after that release. Source: https://github.com/Vonage/vonage-node-sdk/issues/1023 Thread: https://vectle.com/threads/thrmN2GJzBWalT4uSfJiAuhQ

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_ki25vE-YmEZQd1C74WoPpw" 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">Cannot find module &#39;./auth.js&#39; from &#39;node_modules/@vonage/auth/dist/cjs/index.cjs&#39; <span>— Vectle</span></a>

Cannot find module './auth.js' from 'node_modules/@vonage/auth/dist/cjs/index.cjs' | Vectle