#Issue when build

6 messages · Page 1 of 1 (latest)

green compass
#

My code run normal in dev, but when try to preview or build, I will get error like this

error during build:
file:///C:/xampp/htdocs/qwik-be-fo/server/assets/@qwik-city-plan-5bbba746.js:1
import{drizzle as vr}from"drizzle-orm/node-postgres";import{Pool as Sr}from"pg";import{pgTable as Gt,serial as Jt,text as G,timestamp as Mt,integer as rt,doublePrecision as br,json as wr}from"drizzle-orm/pg-core";import{relations as Kt}from"drizzle-orm";import{z as U}from"zod";import{Auth as Pn,skipCSRFCheck as _r}from"@auth/core";import xr from"@auth/core/providers/google";import Er from"@auth/core/providers/github";const kr=!0,Tr=!1;/**
                                                            ^^^^
SyntaxError: Named export 'Pool' not found. The requested module 'pg' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'pg';
const {drizzle: vr}from"drizzle-orm/node-postgres";import{Pool: Sr}from"pg";import{pgTable: Gt,serial: Jt,text: G,timestamp: Mt,integer: rt,doublePrecision: br,json: wr}from"drizzle-orm/pg-core";import{relations: Kt}from"drizzle-orm";import{z: U}from"zod";import{Auth: Pn,skipCSRFCheck: _r} = pkg;
reef hare
#

Its caused by the

type: „module“ 

In your package.json.
Dirty fix: just remove it.
Right fix: check If u can switch the drizzle package from commonjs to es6 module.

green compass
reef hare
#

Its because of the difference of a commonjs module and a es6 module.

#

commonjs modules are exported like:

module.exports = {...}

es6 like:

export default {...}