T
TanStack3w ago
deep-jade

SPA mode monorepo not building: "Cannot access 'pg' before initialization"

When I run pnpm build I get ReferenceError: Cannot access 'pg' before initialization. When I add ssr: { external: ['pg'] } to my vite config, it says:
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'pg' imported from /home/codebench/Dev/ts-start-bug/apps/web/.nitro/vite/services/ssr/assets/router-w0xdFAbu.js
Did you mean to import "pg/lib/index.js"?
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'pg' imported from /home/codebench/Dev/ts-start-bug/apps/web/.nitro/vite/services/ssr/assets/router-w0xdFAbu.js
Did you mean to import "pg/lib/index.js"?
I can't tell if this is a bug or an error with my code. Dev mode seems to work fine. Anyone run into a similar issue? Minimal reproduction: https://github.com/rohanajayjain/ts-start-bug
GitHub
GitHub - rohanajayjain/ts-start-bug
Contribute to rohanajayjain/ts-start-bug development by creating an account on GitHub.
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?