[BUG] Error: undefined is not a constructor (evaluating 'new U($,A)')

Resolved 💬 3 comments Opened Dec 17, 2025 by heathermharmon Closed Dec 18, 2025

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When it tries to create a file it's crashing. The error undefined is not a constructor means something Claude Code expected to be a class (likely a syntax highlighter module) is undefined when it tries to instantiate it with new.

When It Triggers
It appears to crash when Claude Code tries to render file contents - specifically when:

  • Writing new files
  • Showing diffs/patches
  • Displaying code blocks

Says intermittent issue but I tried several times. Happens in Opus and Sonnet models.

What Should Happen?

Should correctly create files.

Error Messages/Logs

● This is a crash in Claude Code itself (the CLI tool), not in your project. Here's what's happening:

  Error Summary

  Error: undefined is not a constructor (evaluating 'new U($,A)')

  Location: Internal Claude Code binary (/$bunfs/root/claude:1137)

  What's Causing It

  The crash is occurring in Claude Code's syntax highlighting system when it tries to display code or file contents. Looking at the stack trace:

  1. useMemo - React is trying to memoize/cache something
  2. f6 component - This is the code display component
  3. MdI() - This appears to be a Tree-sitter based syntax highlighter
  4. IKH.highlight - Fallback highlight.js library

  The error undefined is not a constructor means something Claude Code expected to be a class (likely a syntax highlighter module) is undefined when it tries to instantiate it with new.

  When It Triggers

  It appears to crash when Claude Code tries to render file contents - specifically when:
  - Writing new files
  - Showing diffs/patches
  - Displaying code blocks

  Workaround

  The crash is intermittent. You can try:
  1. Restart Claude Code (exit and re-launch)
  2. Avoid operations that trigger code display temporarily

  How to Report

  Report this at: https://github.com/anthropics/claude-code/issues

  Include:
  - Error message: undefined is not a constructor (evaluating 'new U($,A)')
  - Location: /$bunfs/root/claude:1137:5029
  - Context: Crashes when creating files/displaying code
  - Platform: Linux (el9_7)
  - Stack trace: The useMemo → MdI() → highlight chain

  This is a bug in Claude Code's bundled syntax highlighting, not anything in your code or configuration.

Steps to Reproduce

Creating new folder and writing files.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.0.71

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

Other

Additional Information

A custom project not related to CoHarmonify that I want to keep segregated from CoHarmonify. It's a test project I want to come
back to and see if it's something I want to pursue further.
⎿ Interrupted · What should Claude do instead?

We want to build in the staging environment so I can test a few things.

● Let me create a dedicated Chamber Universe project folder in staging.

● Bash(mkdir -p /home/elevatf7/staging/chamber-universe && ls -la /home/elevatf7/staging/)
⎿ total 1772
drwxr-x--- 17 elevatf7 nobody 12288 Dec 16 21:42 .
drwx--x--x 42 elevatf7 elevatf7 4096 Dec 7 02:00 ..
… +178 lines (ctrl+o to expand)

● Chamber Universe folder created. Now let me add the starter files.

ERROR undefined is not a constructor (evaluating 'new U($,A)')

/$bunfs/root/claude:1137:5029

1134: )+A,I=L+1,L=H.indexOf(
1135 ,I)}while(L!==-1);return D+=H.substr(I),D};opI.exports={stringReplaceAll:OQ9,stringEncaseCRLFWithFirstIndex:SQ9}});var
: $cI=z((Ir8,HcI)=>{var
xQ9=/(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[
\t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi,tpI=/(?:^|\.)(\w+)(?:\(([^)]*)\))?/g,RQ9=/^(['"])((?:\\.|(?!\1)[^\\])*)\1$/,yQ9=/\\(u(?:
[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi,jQ9=new Map([["n",

1136 ],["r","\r"],["t","\t"],["b","\b"],["f","\f"],["v","\v"],["0","\x00"],["\\","\\"],["e","\x1B"],["a","\x07"]]);function epI(H){let
: $=H[0]==="u",A=H[1]==="{";if($&&!A&&H.length===5||H[0]==="x"&&H.length===3)return
String.fromCharCode(parseInt(H.slice(1),16));if($&&A)return String.fromCodePoint(parseInt(H.slice(2,-1),16));return
jQ9.get(H)||H}function vQ9(H,$){let A=[],L=$.trim().split(/\s*,\s*/g),I;for(let D of L){let
B=Number(D);if(!Number.isNaN(B))A.push(B);else if(I=D.match(RQ9))A.push(I[2].replace(yQ9,(f,E,M)=>E?epI(E):M));else throw
Error(
Invalid Chalk template style argument: ${D} (in style '${H}'))}return A}function bQ9(H){tpI.lastIndex=0;let
$=[],A;while((A=tpI.exec(H))!==null){let L=A[1];if(A[2]){let I=vQ9(L,A[2]);$.push([L].concat(I))}else $.push([L])}return $}function
spI(H,$){let A={};for(let I of $)for(let D of I.styles)A[D[0]]=I.inverse?null:D.slice(1);let L=H;for(let[I,D]of
Object.entries(A)){if(!Array.isArray(D))continue;if(!(I in L))throw Error(
Unknown Chalk style:
${I});L=D.length>0?L[I](...D):L[I]}return L}HcI.exports=(H,$)=>{let
A=[],L=[],I=[];if($.replace(xQ9,(D,B,f,E,M,G)=>{if(B)I.push(epI(B));else if(E){let
U=I.join("");I=[],L.push(A.length===0?U:spI(H,A)(U)),A.push({inverse:f,styles:bQ9(E)})}else if(M){if(A.length===0)throw
Error("Found extraneous } in Chalk template literal");L.push(spI(H,A)(I.join(""))),I=[],A.pop()}else
I.push(G)}),L.push(I.join("")),A.length>0){let D=
Chalk template literal is missing ${A.length} closing
bracket${A.length===1?"":"s"} (\}\);throw Error(D)}return L.join("")}});var McI=z((Dr8,EcI)=>{var KxH=lpI(),{stdout:KJA,stderr:F
JA}=rpI(),{stringReplaceAll:hQ9,stringEncaseCRLFWithFirstIndex:uQ9}=apI(),{isArray:X5$}=Array,LcI=["ansi","ansi","ansi256","ansi16m
"],LKH=Object.create(null),kQ9=(H,$={})=>{if($.level&&!(Number.isInteger($.level)&&$.level>=0&&$.level<=3))throw Error("The
level
option should be an integer from 0 to 3");let A=KJA?KJA.level:0;H.level=$.level===void 0?A:$.level};class
IcI{constructor(H){return DcI(H)}}var DcI=(H)=>{let $={};return kQ9($,H),$.template=(...A)=>fcI($.template,...A),Object.setPrototyp
eOf($,J5$.prototype),Object.setPrototypeOf($.template,$),$.template.constructor=()=>{throw Error("
chalk.constructor() is
deprecated. Use
new chalk.Instance() instead.")},$.template.Instance=IcI,$.template};function J5$(H){return DcI(H)}for(let[H,$]of
Object.entries(KxH))LKH[H]={get(){let A=W5$(this,CJA($.open,$.close,this._styler),this._isEmpty);return
Object.defineProperty(this,H,{value:A}),A}};LKH.visible={get(){let H=W5$(this,this._styler,!0);return
Object.defineProperty(this,"visible",{value:H}),H}};var BcI=["rgb","hex","keyword","hsl","hsv","hwb","ansi","ansi256"];for(let H of
BcI)LKH[H]={get(){let{level:$}=this;return function(...A){let
L=CJA(KxH.color[LcI[$]][H](...A),KxH.color.close,this._styler);return W5$(this,L,this._isEmpty)}}};for(let H of BcI){let
$="bg"+H[0].toUpperCase()+H.slice(1);LKH[$]={get(){let{level:A}=this;return function(...L){let
I=CJA(KxH.bgColor[LcI[A]][H](...L),KxH.bgColor.close,this._styler);return W5$(this,I,this._isEmpty)}}}}var
gQ9=Object.defineProperties(()=>{},{...LKH,level:{enumerable:!0,get(){return
this._generator.level},set(H){this._generator.level=H}}}),CJA=(H,$,A)=>{let L,I;if(A===void 0)L=H,I=$;else
L=A.openAll+H,I=$+A.closeAll;return{open:H,close:$,openAll:L,closeAll:I,parent:A}},W5$=(H,$,A)=>{let
L=(...I)=>{if(X5$(I[0])&&X5$(I[0].raw))return AcI(L,fcI(L,...I));return AcI(L,I.length===1?""+I[0]:I.join(" "))};return
Object.setPrototypeOf(L,gQ9),L._generator=H,L._styler=$,L._isEmpty=A,L},AcI=(H,$)=>{if(H.level<=0||!$)return H._isEmpty?"":$;let
A=H._styler;if(A===void 0)return $;let{openAll:L,closeAll:I}=A;if($.indexOf("\x1B")!==-1)while(A!==void
0)$=hQ9($,A.close,A.open),A=A.parent;let D=$.indexOf(

1137 );if(D!==-1)$=uQ9($,I,L,D);return L+$+I},WJA,fcI=(H,...$)=>{let[A]=$;if(!X5$(A)||!X5$(A.raw))return $.join(" ");let
: L=$.slice(1),I=[A.raw[0]];for(let
D=1;D<A.length;D++)I.push(String(L[D-1]).replace(/[{}\\]/g,"\\$&"),String(A.raw[D]));if(WJA===void 0)WJA=$cI();return
WJA(H,I.join(""))};Object.defineProperties(J5$.prototype,LKH);var
K5$=J5$();K5$.supportsColor=KJA;K5$.stderr=J5$({level:FJA?FJA.level:0});K5$.stderr.supportsColor=FJA;EcI.exports=K5$});var
QJA=z((Tf)=>{var mQ9=Tf&&Tf.__importDefault||function(H){return H&&H.__esModule?H:{default:H}};Object.defineProperty(Tf,"__esModule
",{value:!0});Tf.parse=Tf.stringify=Tf.toJson=Tf.fromJson=Tf.DEFAULT_THEME=Tf.plain=void 0;var C4=mQ9(McI()),dQ9=function(H){return
H};Tf.plain=dQ9;Tf.DEFAULT_THEME={keyword:C4.default.blue,built_in:C4.default.cyan,type:C4.default.cyan.dim,literal:C4.default.blu
e,number:C4.default.green,regexp:C4.default.red,string:C4.default.red,subst:Tf.plain,symbol:Tf.plain,class:C4.default.blue,function
:C4.default.yellow,title:Tf.plain,params:Tf.plain,comment:C4.default.green,doctag:C4.default.green,meta:C4.default.grey,"meta-keywo
rd":Tf.plain,"meta-string":Tf.plain,section:Tf.plain,tag:C4.default.grey,name:C4.default.blue,"builtin-name":Tf.plain,attr:C4.defau
lt.cyan,attribute:Tf.plain,variable:Tf.plain,bullet:Tf.plain,code:Tf.plain,emphasis:C4.default.italic,strong:C4.default.bold,formul
a:Tf.plain,link:C4.default.underline,quote:Tf.plain,"selector-tag":Tf.plain,"selector-id":Tf.plain,"selector-class":Tf.plain,"selec
tor-attr":Tf.plain,"selector-pseudo":Tf.plain,"template-tag":Tf.plain,"template-variable":Tf.plain,addition:C4.default.green,deleti
on:C4.default.red,default:Tf.plain};function GcI(H){var $={};for(var A=0,L=Object.keys(H);A<L.length;A++){var
I=L[A],D=H[I];if(Array.isArray(D))$[I]=D.reduce(function(B,f){return f==="plain"?Tf.plain:B[f]},C4.default);else
$[I]=C4.default[D]}return $}Tf.fromJson=GcI;function UcI(H){var $={};for(var A=0,L=Object.keys($);A<L.length;A++){var
I=L[A],D=$[I];$[I]=D._styles}return $}Tf.toJson=UcI;function pQ9(H){return JSON.stringify(UcI(H))}Tf.stringify=pQ9;function
cQ9(H){return GcI(JSON.parse(H))}Tf.parse=cQ9});var Q5$=z((QK)=>{var
XcI=QK&&QK.__createBinding||(Object.create?function(H,$,A,L){if(L===void
0)L=A;Object.defineProperty(H,L,{enumerable:!0,get:function(){return $[A]}})}:function(H,$,A,L){if(L===void
0)L=A;H[L]=$[A]}),lQ9=QK&&QK.__setModuleDefault||(Object.create?function(H,$){Object.defineProperty(H,"default",{enumerable:!0,valu
e:$})}:function(H,$){H.default=$}),JcI=QK&&QK.__importStar||function(H){if(H&&H.__esModule)return H;var $={};if(H!=null){for(var A
in H)if(A!=="default"&&Object.prototype.hasOwnProperty.call(H,A))XcI($,H,A)}return
lQ9($,H),$},iQ9=QK&&QK.__exportStar||function(H,$){for(var A in
H)if(A!=="default"&&!Object.prototype.hasOwnProperty.call($,A))XcI($,H,A)},nQ9=QK&&QK.__importDefault||function(H){return H&&H.__es
Module?H:{default:H}};Object.defineProperty(QK,"__esModule",{value:!0});QK.supportsLanguage=QK.listLanguages=QK.highlight=void
0;var C5$=JcI(oq$()),rQ9=JcI(SpI()),oQ9=nQ9(kpI()),F5$=QJA();function VJA(H,$,A){if($===void 0)$={};switch(H.type){case"text":{var
L=H.data;if(A===void 0)return($.default||F5$.DEFAULT_THEME.default||F5$.plain)(L);return L}case"tag":{var
I=/hljs-(\w+)/.exec(H.attribs.class);if(I){var D=I[1],B=H.childNodes.map(function(f){return
VJA(f,$,D)}).join("");return($[D]||F5$.DEFAULT_THEME[D]||F5$.plain)(B)}return H.childNodes.map(function(f){return
VJA(f,$)}).join("")}}throw Error("Invalid node type "+H.type)}function aQ9(H,$){if($===void 0)$={};var
A=rQ9.parseFragment(H,{treeAdapter:oQ9.default});return A.childNodes.map(function(L){return VJA(L,$)}).join("")}function
WcI(H,$){if($===void 0)$={};var A;if($.language)A=C5$.highlight(H,{language:$.language,ignoreIllegals:$.ignoreIllegals}).value;else
A=C5$.highlightAuto(H,$.languageSubset).value;return aQ9(A,$.theme)}QK.highlight=WcI;function tQ9(){return
C5$.listLanguages()}QK.listLanguages=tQ9;function
sQ9(H){return!!C5$.getLanguage(H)}QK.supportsLanguage=sQ9;QK.default=WcI;iQ9(QJA(),QK)});function
FcI({code:H,filePath:$,dim:A=!1}){let L=KcI.extname($).slice(1),I=FxH.useMemo(()=>{let
D=zJH(H);try{if(IKH.supportsLanguage(L))return IKH.highlight(D,{language:L});else return u(
Language not supported while
highlighting code, falling back to markdown: ${L}),IKH.highlight(D,{language:"markdown"})}catch(B){if(B instanceof
Error&&B.message.includes("Unknown language"))return u(
Language not supported while highlighting code, falling back to markdown:
${B}),IKH.highlight(D,{language:"markdown"})}},[H,L]);return
FxH.default.createElement(Q,{dimColor:A},FxH.default.createElement(vf,null,I??""))}var IKH,KcI,FxH;var
CcI=K(()=>{yH();o$();eB();IKH=b(Q5$(),1),KcI=require("path"),FxH=b(DH(),1)});var Lx,Ix,eQ9=80,f6;var
JBH=K(()=>{yH();CcI();rX$();Lx=b(DH(),1),Ix=b(DH(),1),f6=Ix.memo(function({code:$,filePath:A,width:L,dim:I=!1}){let
D=Ix.useRef(null),[B,f]=Ix.useState(L||eQ9),[E]=WD(),M=Ix.useMemo(()=>{let U=MdI();if(U===null)return null;return new
U($,A)},[$,A]);Ix.useEffect(()=>{if(!L&&D.current){let{width:U}=Ar$(D.current);if(U>0)f(U-2)}},[L]);let
G=Ix.useMemo(()=>{if(M===null)return null;return M.render(E,B,I)},[M,E,B,I]);return
Lx.createElement(q,{ref:D},G?Lx.createElement(q,{flexDirection:"column"},G.map((U,X)=>Lx.createElement(Q,{key:X},Lx.createElement(v
f,null,U)))):Lx.createElement(FcI,{code:$,filePath:A,dim:I}))})});function DKH({file_path:H,operation:$,patch:A,firstLine:L,content
:I,style:D,verbose:B}){let{columns:f}=VI(),E=WM.createElement(q,{flexDirection:"row"},WM.createElement(Q,{color:"subtle"},"User
rejected ",$," to "),WM.createElement(Q,{bold:!0,color:"subtle"},B?H:VcI.relative(i$(),H)));if(D==="condensed"&&!B)return
WM.createElement(xA,null,E);if($==="write"&&I!==void 0){let M=I.split(

1138: ),U=M.length-QcI,X=B?I:M.slice(0,QcI).join(
1139 );return WM.createElement(xA,null,WM.createElement(q,{flexDirection:"column"},E,WM.createElement(f6,{code:X||"(No
: content)",filePath:H,width:f-12,dim:!0}),!B&&U>0&&WM.createElement(Q,{dimColor:!0},"\u2026 +",U,"
lines")))}if(!A||A.length===0)return WM.createElement(xA,null,E);return WM.createElement(xA,null,WM.createElement(q,{flexDirection:
"column"},E,b2(A.map((M)=>WM.createElement(q,{flexDirection:"column",key:M.newStart},WM.createElement(h2,{patch:M,dim:!0,width:f-12
,filePath:H,firstLine:L}))),(M)=>WM.createElement(q,{key:
ellipsis-${M}},WM.createElement(Q,{dimColor:!0},"...")))))}var
VcI,WM,QcI=10;var PJA=K(()=>{yH();sI();fa();JBH();F9();l0();VcI=require("path"),WM=b(DH(),1)});function
HV9({filePath:H,content:$,verbose:A}){let{columns:L}=VI(),I=$||"(No content)",D=$.split(ZJA.EOL).length,B=D-PcI;return
C9.createElement(xA,null,C9.createElement(q,{flexDirection:"column"},C9.createElement(Q,null,"Wrote
",C9.createElement(Q,{bold:!0},D)," lines to"," ",C9.createElement(Q,{bold:!0},A?H:WBH.relative(i$(),H))),C9.createElement(q,{flexD
irection:"column"},C9.createElement(f6,{code:A?I:I.split(

1140: ).slice(0,PcI).filter((f)=>f.trim()!=="").join(

  • <anonymous> (/$bunfs/root/claude:1137:5029)
  • useMemo (/$bunfs/root/claude:170:102600)
  • <anonymous> (/$bunfs/root/claude:45:7784)
  • <anonymous> (/$bunfs/root/claude:1137:4975)
  • hU (/$bunfs/root/claude:170:20695)
  • gU (/$bunfs/root/claude:170:39063)
  • zH (/$bunfs/root/claude:170:36448)
  • PH (/$bunfs/root/claude:170:35983)
  • xe (/$bunfs/root/claude:170:52039)
  • V5 (/$bunfs/root/claude:170:85835)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗