{"record":{"id":"6c37c2d36bc91fac","repo":"vitejs/vite","slug":"vite-the-requested-module-rawid-does-not-pr","errorCode":null,"errorMessage":"[vite] The requested module '${rawId}' does not provide an export named '${lastBinding}'","messagePattern":"\\[vite\\] The requested module '(.+?)' does not provide an export named '(.+?)'","errorType":"exception","errorClass":"SyntaxError","httpStatus":null,"severity":"error","filePath":"packages/vite/src/shared/ssrTransform.ts","lineNumber":43,"sourceCode":"  rawId: string,\n  moduleType: string | undefined,\n  metadata?: SSRImportMetadata,\n): void {\n  // No normalization needed if the user already dynamic imports this module\n  if (metadata?.isDynamicImport) return\n\n  // If the user named imports a specifier that can't be analyzed, error.\n  // If the module doesn't import anything explicitly, e.g. `import 'foo'` or\n  // `import * as foo from 'foo'`, we can skip.\n  if (metadata?.importedNames?.length) {\n    const missingBindings = metadata.importedNames.filter((s) => !(s in mod))\n    if (missingBindings.length) {\n      const lastBinding = missingBindings[missingBindings.length - 1]\n\n      // For invalid named exports only, similar to how Node.js errors for top-level imports.\n      // But since we transform as dynamic imports, we need to emulate the error manually.\n      if (moduleType === 'module') {\n        throw new SyntaxError(\n          `[vite] The requested module '${rawId}' does not provide an export named '${lastBinding}'`,\n        )\n      } else {\n        // For non-ESM, named imports is done via static analysis with cjs-module-lexer in Node.js.\n        // Copied from Node.js\n        throw new SyntaxError(`\\\n[vite] Named export '${lastBinding}' not found. The requested module '${rawId}' is a CommonJS module, which may not support all module.exports as named exports.\nCommonJS modules can always be imported via the default export, for example using:\n\nimport pkg from '${rawId}';\nconst {${missingBindings.join(', ')}} = pkg;\n`)\n      }\n    }\n  }\n}\n","sourceCodeStart":25,"sourceCodeEnd":60,"githubUrl":"https://github.com/vitejs/vite/blob/b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab/packages/vite/src/shared/ssrTransform.ts#L25-L60","documentation":"Thrown by analyzeImportedModDifference() during SSR when a named import references an export that does not exist on an ESM dependency. Vite transforms SSR imports to dynamic imports for live binding/HMR, so it manually reproduces the SyntaxError Node.js would raise for a missing named export from an ESM module.","triggerScenarios":"SSR code does `import { foo } from 'pkg'` where pkg is an ESM module (package type 'module') and has no export named foo. The check at ssrTransform.ts:42 throws for the last missing binding found via metadata.importedNames.","commonSituations":"Typo in an imported name (e.g. import { defualt } instead of default). Upgrading a dependency that renamed/removed an export. Tree-shaken or conditionally-exported named exports that don't exist under the current resolve conditions. Importing a named export from a package that only has a default export.","solutions":["Verify the export name against the dependency's actual .d.ts or package exports (check the version you resolved).","Use the default import when the package only exports default: import pkg from 'pkg' then access pkg.foo.","Pin or upgrade the dependency to a version that has the named export you need.","For CommonJS deps, import via default and destructure (the sibling error message at ssrTransform.ts:49 guides this)."],"exampleFix":"// before\nimport { defualt } from 'pkg' // typo, throws\n// after\nimport { default } from 'pkg'","handlingStrategy":"validation","validationCode":"// verify named exports exist before relying on them at runtime\nconst mod = await import('pkg')\nconst needed = ['foo']\nconst missing = needed.filter(k => !(k in mod))\nif (missing.length) throw new Error(`pkg is missing exports: ${missing.join(', ')}`)","typeGuard":"function hasNamedExport(mod: any, name: string): boolean {\n  return name in mod || name in (mod.__esModule ? mod : {})\n}","tryCatchPattern":"try {\n  await import('pkg')\n} catch (e) {\n  if (e instanceof SyntaxError && /does not provide an export named/.test(e.message)) {\n    // fall back to default import + destructure\n    const pkg = (await import('pkg')).default\n    const { foo } = pkg\n  } else throw e\n}","preventionTips":["Cross-check named imports against the dependency's .d.ts or package exports for the resolved version.","Prefer default imports for CommonJS-only packages.","Lock dependency versions to avoid silent export renames."],"tags":["ssr","imports","named-exports","dependencies"],"backgroundTag":null,"analyzedSha":"b4d66fee14d970f45b8a6f3d7d6aee73ca9b88ab","analyzedAt":"2026-08-11T11:49:19.515Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}