TanStackT
TanStack3mo ago
13 replies
interior-tomato

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"?


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
Contribute to rohanajayjain/ts-start-bug development by creating an account on GitHub.
GitHub - rohanajayjain/ts-start-bug
Was this page helpful?