to connect to a remote database. As soon as I import and use
pg
pg
in one of my funtions though, I get errors like this during
npm run build
npm run build
:
$ npm run build> [email protected] build> next build ▲ Next.js 14.0.4Failed to compile../node_modules/pg-connection-string/index.js:76:69Module not found: Can't resolve 'fs'https://nextjs.org/docs/messages/module-not-foundImport trace for requested module:./node_modules/pg/lib/connection-parameters.js./node_modules/pg/lib/client.js./node_modules/pg/lib/index.js./app/api/pg/route.js...
$ npm run build> [email protected] build> next build ▲ Next.js 14.0.4Failed to compile../node_modules/pg-connection-string/index.js:76:69Module not found: Can't resolve 'fs'https://nextjs.org/docs/messages/module-not-foundImport trace for requested module:./node_modules/pg/lib/connection-parameters.js./node_modules/pg/lib/client.js./node_modules/pg/lib/index.js./app/api/pg/route.js...
How can I use
pg
pg
in a Next.js project that I want to deploy to Cloudflare Pages?