Tanstack Start and CommonJS modules
Hello,
I have converted my project to Tanstack Start from Next.js, and it was a fantastic experience until I ran into this error in the terminal upon build and dev commands. I'm using yarn.
[8:19:53 PM] ERROR require() of ES Module /Users/mathias/GitHub/flowthings/node_modules/string-width/index.js from /Users/mathias/GitHub/flowthings/node_modules/wide-align/align.js not supported.
Instead change the require of index.js in /Users/mathias/GitHub/flowthings/node_modules/wide-align/align.js to a dynamic import() which is available in all CommonJS modules.
Instead change the require of index.js in node_modules/wide-align/align.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (node_modules/wide-align/align.js:2:19)
I tried adding resolutions to my package.json without any luck:
"resolutions": {
"string-width": "4.2.3"
}
}
How can I fix this error? The module is used by one of my dependencies. I suspect it to be my TipTap editor somewhere. It is hard to locate.
4 Replies
genetic-orange•10mo ago
you could try putting this dep into vite.ssr.noExternal
you could also disable SSR for the affected routes by setting
ssr: false
in the route definition
if all this does not help we need a complete minimal exampleexotic-emeraldOP•10mo ago
Thanks for the suggestions. I will try. I did hope something could be done without disabling SSR
genetic-orange•10mo ago
vite.ssr.noExternal
won't disable SSR
btw I don't see why the "resolutions" would have change a thing here?
the error message is about "wide-align/align.js"exotic-emeraldOP•10mo ago
Okay I asked around and tried it out. It did not work. I will try see if I can determine where this package is used, and then get back to you if I can isolate it. Thanks for taking the time!