remix-run/remix · error · SyntaxError

${errors.map((error) => error.message).join('\n')}

Error message

${errors.map((error) => error.message).join('\n')}

What it means

transformModule runs esbuild-style transform (via the TS transform pipeline) on a module and checks `result.errors`. Any transform/parse diagnostics become a thrown error joining the diagnostic messages — i.e. your file has a syntax error the transform could not recover from.

Source

Thrown at packages/node-tsx/src/lib/transform.ts:36

  [key in TsconfigTransformCompilerOptionKey]?: string
}

type TsconfigTransformCompilerOptionsIssue = {
  key: TsconfigTransformCompilerOptionKey
  value: unknown
}

export function transformModule(filePath: string, source: string): string {
  let compilerOptions = getTsconfigCompilerOptions(filePath)
  let result = transformSync(filePath, source, {
    lang: getLanguage(filePath),
    sourceType: getSourceType(filePath, source),
    sourcemap: true,
    ...getJsxTransformOptions(filePath, compilerOptions),
  })

  if (result.errors.length > 0) {
    throw createTransformError(result.errors)
  }

  if (result.map == null) {
    return result.code
  }

  return `${result.code}\n//# sourceMappingURL=data:application/json;base64,${Buffer.from(
    JSON.stringify(result.map),
  ).toString('base64')}`
}

function createTransformError(errors: OxcError[]): SyntaxError {
  let message = errors.map((error) => error.message).join('\n')
  let error = new SyntaxError(message)
  error.stack = errors.map(formatTransformError).join('\n\n')
  return error
}

View on GitHub (pinned to 9696913134)

Solutions

  1. Fix the syntax error at the file/position given in the joined messages
  2. Run `npx tsc --noEmit` or your linter to surface the syntax problem
  3. Check the file's JSX/TSX settings match your tsconfig
Defensive patterns

Strategy: type-guard

Validate before calling

import { runTsc } from './typecheck.ts'
const diagnostics = await runTsc(filePath)
if (diagnostics.length > 0) throw new Error('Fix syntax errors before loading')

Type guard

const hasTransformDiagnostics = (result: { errors: unknown[] }): boolean =>
  result.errors.length > 0

Try / catch

catch (error) {
  if (error instanceof Error && /Transform failed|error/i.test(error.message)) {
    // surface the per-file syntax diagnostics to the user
  }
  throw error
}

Prevention

When it happens

Trigger: Importing a .ts/.tsx file (through Remix node-tsx loading) that contains a syntax error or unsupported syntax for the configured transform, producing nonzero `result.errors`.

Common situations: Syntax errors in TypeScript/JSX files loaded at runtime by node-tsx; unsupported syntax for the configured target/JSX factory; files with mismatched extensions.

Related errors


AI-assisted analysis of remix-run/remix@9696913134 (2026-08-27). Data as JSON: /api/errors/93f427ab2c714fda. Report an issue: GitHub.