T
TanStack3w ago
like-gold

[ERR_MODULE_NOT_FOUND]: Cannot find module ... `esm` ... Did you mean to import ... `cjs` ...?

Hey all! First time poster here. Wish I didn't hvae to... I've been trying to deploy my TanStack Router SSR app to Netlify for the last couple days and I'm starting to lose hope. I thought something like that would be a breeze in 2025 but it looks like it's still a mess. So many yet so few pages documenting what needs to be done and all showing something different. Briefly looked at the TanStack Start page but seeing how it's a "framework" I ignored it... until today when I realised that it's not really a framework but just Router with a bunch of build tools on top of it. So I installed it and finally managed to get my project to build and deploy to Netlify but now it keeps throwing the following error in the function logs:
3 Replies
like-gold
like-goldOP3w ago
Aug 8, 05:23:26 PM: 95892577 ERROR [request error] [unhandled] [GET] https://my-test-app.netlify.app/
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/var/task/node_modules/bs58/src/esm/index.js' imported from /var/task/chunks/_/ssr.mjs
Did you mean to import "file:///var/task/node_modules/.nitro/bs58@6.0.0/src/cjs/index.cjs"?
at finalizeResolution (node:internal/modules/esm/resolve:287:11)
... 7 lines matching cause stack trace ...
at ModuleJob._link (node:internal/modules/esm/module_job:130:49) {
cause: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/var/task/node_modules/bs58/src/esm/index.js' imported from /var/task/chunks/_/ssr.mjs
Did you mean to import "file:///var/task/node_modules/.nitro/bs58@6.0.0/src/cjs/index.cjs"?
at finalizeResolution (node:internal/modules/esm/resolve:287:11)
at moduleResolve (node:internal/modules/esm/resolve:956:10)
at moduleResolveWithNodePath (node:internal/modules/esm/resolve:1192:14)
at defaultResolve (node:internal/modules/esm/resolve:1235:79)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:642:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:591:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:574:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:236:38)
at ModuleJob._link (node:internal/modules/esm/module_job:130:49) {
code: 'ERR_MODULE_NOT_FOUND',
url: 'file:///var/task/node_modules/bs58/src/esm/index.js'
},
statusCode: 500,
fatal: false,
unhandled: true,
statusMessage: undefined,
data: undefined
}
Aug 8, 05:23:26 PM: 95892577 ERROR [request error] [unhandled] [GET] https://my-test-app.netlify.app/
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/var/task/node_modules/bs58/src/esm/index.js' imported from /var/task/chunks/_/ssr.mjs
Did you mean to import "file:///var/task/node_modules/.nitro/bs58@6.0.0/src/cjs/index.cjs"?
at finalizeResolution (node:internal/modules/esm/resolve:287:11)
... 7 lines matching cause stack trace ...
at ModuleJob._link (node:internal/modules/esm/module_job:130:49) {
cause: Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/var/task/node_modules/bs58/src/esm/index.js' imported from /var/task/chunks/_/ssr.mjs
Did you mean to import "file:///var/task/node_modules/.nitro/bs58@6.0.0/src/cjs/index.cjs"?
at finalizeResolution (node:internal/modules/esm/resolve:287:11)
at moduleResolve (node:internal/modules/esm/resolve:956:10)
at moduleResolveWithNodePath (node:internal/modules/esm/resolve:1192:14)
at defaultResolve (node:internal/modules/esm/resolve:1235:79)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:642:12)
at #cachedDefaultResolve (node:internal/modules/esm/loader:591:25)
at ModuleLoader.resolve (node:internal/modules/esm/loader:574:38)
at ModuleLoader.getModuleJobForImport (node:internal/modules/esm/loader:236:38)
at ModuleJob._link (node:internal/modules/esm/module_job:130:49) {
code: 'ERR_MODULE_NOT_FOUND',
url: 'file:///var/task/node_modules/bs58/src/esm/index.js'
},
statusCode: 500,
fatal: false,
unhandled: true,
statusMessage: undefined,
data: undefined
}
It feels like I've tried everything at this point and nothing seems to work. I changed Node from v22 to v20, I tried installing this bs58 library in my own package.json file (it's not a dependency of my app, it must be a dependency of some other dependency) but it doesn't really help because as soon as I do some other library fails with the same error and I don't want to start adding every single library to my own package.json file. Does anyone have any idea what is going on and why is it trying to load files that don't exist? I see a few similar bug reports from a month and two back with the same errors but they're all a bit different and none gives a generic answer apart from "I upgrade that library".
like-gold
like-goldOP3w ago
Here are the folder structures (although I don't think it's because of that as it feels as if the loader doesn't know what to load). I'm using pnpm hence it's not a flat structure like with NPM.
No description
No description
dependent-tan
dependent-tan3w ago
it's not really a framework but just Router with a bunch of build tools on top of it.
so .... what would be your definition of a "framework" ?

Did you find this page helpful?