vicaryV
Denoβ€’2mo ago
vicary

vite crashes on pg-types

When importing npm:pg-types@^4.1.0 during SSR, it fails with the following error.
TypeError: Cannot add property Encoder, object is not extensible

It's caused by a common NPM max compat export pattern below in postgres-bytea.

Update
Found the solution before I can post this, sharing it here. Just add external to your vite.config.js.
export default defineConfig({
  plugins: [fresh(), tailwindcss()],
  ssr: {
    external: ["postgres-bytea"]
  }
});
Was this page helpful?