{"record":{"id":"f6a9438de23ef959","repo":"evanw/esbuild","slug":"unexpected-end-of-file-before-a-closing-s","errorCode":null,"errorMessage":"Unexpected end of file before a closing %s","messagePattern":"Unexpected end of file before a closing (.+?)","errorType":"panic","errorClass":"LexerPanic","httpStatus":null,"severity":"error","filePath":"internal/js_parser/js_parser.go","lineNumber":5554,"sourceCode":"\n\t\t\treturn js_ast.Expr{Loc: loc, Data: &js_ast.EJSXElement{\n\t\t\t\tTagOrNil:         startTagOrNil,\n\t\t\t\tProperties:       properties,\n\t\t\t\tNullableChildren: nullableChildren,\n\t\t\t\tCloseLoc:         lessThanLoc,\n\t\t\t\tIsTagSingleLine:  isSingleLine,\n\t\t\t}}\n\n\t\tcase js_lexer.TEndOfFile:\n\t\t\tstartTag := tagOrFragmentHelpText(startText)\n\t\t\tmsg := logger.Msg{\n\t\t\t\tKind:  logger.Error,\n\t\t\t\tData:  p.tracker.MsgData(p.lexer.Range(), fmt.Sprintf(\"Unexpected end of file before a closing %s\", startTag)),\n\t\t\t\tNotes: []logger.MsgData{p.tracker.MsgData(startRange, fmt.Sprintf(\"The opening %s is here:\", startTag))},\n\t\t\t}\n\t\t\tmsg.Data.Location.Suggestion = fmt.Sprintf(\"</%s>\", startText)\n\t\t\tp.log.AddMsg(msg)\n\t\t\tpanic(js_lexer.LexerPanic{})\n\n\t\tdefault:\n\t\t\tp.lexer.Unexpected()\n\t\t}\n\t}\n}\n\nfunc (p *parser) parseTemplateParts(includeRaw bool) (parts []js_ast.TemplatePart, legacyOctalLoc logger.Loc) {\n\t// Allow \"in\" inside template literals\n\toldAllowIn := p.allowIn\n\tp.allowIn = true\n\n\tfor {\n\t\tp.lexer.Next()\n\t\tvalue := p.parseExpr(js_ast.LLowest)\n\t\ttailLoc := p.lexer.Loc()\n\t\tp.lexer.RescanCloseBraceAsTemplateToken()\n\t\tif includeRaw {","sourceCodeStart":5536,"sourceCodeEnd":5572,"githubUrl":"https://github.com/evanw/esbuild/blob/f6058f8364fe7ab91ca57a83e02577ed74c9cae4/internal/js_parser/js_parser.go#L5536-L5572","documentation":"While parsing a JSX element, the lexer reached end-of-file before the matching closing tag. esbuild reports the opening tag location and suggests the exact '</tagName>' to add.","triggerScenarios":"'<div>...' with no '</div>' before EOF, or an unbalanced/self-closing element missing its '/>'.","commonSituations":"Truncated file; forgotten closing tag; a nested child element that swallowed the close; commented-out closing tag.","solutions":["Add the matching closing tag '</tagName>'.","Self-close the element with '/>' if it has no children.","Check for accidentally commented-out or deleted closing tags."],"exampleFix":"// before\n<div>hello\n// after\n<div>hello</div>","handlingStrategy":"validation","validationCode":"import \"github.com/evanw/esbuild/pkg/api\"\nres := api.Transform(jsx, api.TransformOptions{Loader: api.LoaderJSX})\nfor _, m := range res.Errors {\n  if strings.Contains(m.Text, \"Unexpected end of file before a closing\") {\n    // m.Location + notes point at the unclosed opening tag\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use a JSX-aware editor/eslint-plugin-react that balances tags.","Self-close elements with '/>' when they have no children.","Run tsc --jsx on .tsx files to catch unclosed elements before bundling."],"tags":["syntax-error","parser","jsx"],"backgroundTag":null,"analyzedSha":"f6058f8364fe7ab91ca57a83e02577ed74c9cae4","analyzedAt":"2026-08-09T18:37:22.223Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}