You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a project that uses opennextjs/cloudflare and also pg-node.
When running npm run preview:worker, I get:
✘ [ERROR] Build failed with 1 error:
✘ [ERROR] Could not resolve "pg-cloudflare"
.worker-next/.next/standalone/node_modules/pg/lib/stream.js:41:41:
41 │ const { CloudflareSocket } = require('pg-cloudflare')
╵ ~~~~~~~~~~~~~~~
The module "./dist/index.js" was not found on the file system:
.worker-next/.next/standalone/node_modules/pg-cloudflare/package.json:13:15:
13 │ "workerd": "./dist/index.js",
╵ ~~~~~~~~~~~~~~~~~
You can mark the path "pg-cloudflare" as external to exclude it from the bundle, which will
remove this error. You can also surround this "require" call with a try/catch block to handle this
failure at run-time instead of bundle-time.
I discovered that this is because the build step does not copy all files in node_modules/pg-cloudflare/dist/ to .worker-next/.next/standalone/node_modules/pg-cloudflare/dist. It only copies empty.js, but as you can see, more is required.
Changing the build script to: cloudflare && cp node_modules/pg-cloudflare/dist/* .worker-next/.next/standalone/node_modules/pg-cloudflare/dist
fixed the issue for me, but thats obviously a hack and the cloudflare build should be fixed.
I had the same issue. To fix it, I had to update the package.json file for the "pg-cloudflare" package. Specifically, I modified the exports section as follows:
Describe the bug
I have a project that uses
opennextjs/cloudflare
and alsopg-node
.When running
npm run preview:worker
, I get:I discovered that this is because the build step does not copy all files in
node_modules/pg-cloudflare/dist/
to.worker-next/.next/standalone/node_modules/pg-cloudflare/dist
. It only copiesempty.js
, but as you can see, more is required.Changing the build script to:
cloudflare && cp node_modules/pg-cloudflare/dist/* .worker-next/.next/standalone/node_modules/pg-cloudflare/dist
fixed the issue for me, but thats obviously a hack and the
cloudflare
build should be fixed.Steps to reproduce
npm run preview:worker
Expected behavior
Expected the build to include all files that are necessary to run the app on workerd.
Including all the files from
node_modules/pg-cloudflare/dist
@opennextjs/cloudflare version
0.2.1
Node.js version
20.17.0
Wrangler version
3.92.0
next info output
Node.js v20.17.0 Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000 Available memory (MB): 32768 Available CPU cores: 10 Binaries: Node: 20.17.0 npm: 10.8.2 Yarn: N/A pnpm: N/A Relevant Packages: next: 15.0.3 // Latest available version is detected (15.0.3). eslint-config-next: N/A react: 18.3.1 react-dom: 18.3.1 typescript: N/A Next.js Config: output: N/A
Additional context
No response
The text was updated successfully, but these errors were encountered: