node modules error when importing postgres in my worker.js file

I'm trying to add hyperdrive to my worker, when I import the postgres package into my worker.js file I get this error:
[WARNING] The package "node:events" wasn't found on the file system but is built into node.

Your Worker may throw errors at runtime unless you enable the "nodejs_compat" compatibility flag.
Refer to https://developers.cloudflare.com/workers/runtime-apis/nodejs/ for more details. Imported
from:
- node_modules\postgres\cf\polyfills.js

▲ [WARNING] The package "node:stream" wasn't found on the file system but is built into node. Your Worker may throw errors at runtime unless you enable the "nodejs_compat" compatibility
flag. Refer to https://developers.cloudflare.com/workers/runtime-apis/nodejs/ for more details.
Imported from:
- node_modules\postgres\cf\src\large.js
- node_modules\postgres\cf\src\connection.js


▲ [WARNING] The package "node:buffer" wasn't found on the file system but is built into node. Your Worker may throw errors at runtime unless you enable the "nodejs_compat" compatibility
flag. Refer to https://developers.cloudflare.com/workers/runtime-apis/nodejs/ for more details.
Imported from:
- node_modules\postgres\cf\src\connection.js
- node_modules\postgres\cf\src\types.js
- node_modules\postgres\cf\src\subscribe.js
- node_modules\postgres\cf\polyfills.js
- node_modules\postgres\cf\src\bytes.js
[WARNING] The package "node:events" wasn't found on the file system but is built into node.

Your Worker may throw errors at runtime unless you enable the "nodejs_compat" compatibility flag.
Refer to https://developers.cloudflare.com/workers/runtime-apis/nodejs/ for more details. Imported
from:
- node_modules\postgres\cf\polyfills.js

▲ [WARNING] The package "node:stream" wasn't found on the file system but is built into node. Your Worker may throw errors at runtime unless you enable the "nodejs_compat" compatibility
flag. Refer to https://developers.cloudflare.com/workers/runtime-apis/nodejs/ for more details.
Imported from:
- node_modules\postgres\cf\src\large.js
- node_modules\postgres\cf\src\connection.js


▲ [WARNING] The package "node:buffer" wasn't found on the file system but is built into node. Your Worker may throw errors at runtime unless you enable the "nodejs_compat" compatibility
flag. Refer to https://developers.cloudflare.com/workers/runtime-apis/nodejs/ for more details.
Imported from:
- node_modules\postgres\cf\src\connection.js
- node_modules\postgres\cf\src\types.js
- node_modules\postgres\cf\src\subscribe.js
- node_modules\postgres\cf\polyfills.js
- node_modules\postgres\cf\src\bytes.js
my wrangler.toml:
name = "xxx-api"
main = "worker.js"

compatibility_flags = [ "nodejs_compat" ]
compatibility_date = "2024-09-23"

[env.production]
compatibility_flags = ["nodejs_compat"]

[unsafe.metadata.observability]
enabled = true

[[hyperdrive]]
binding = "HYPERDRIVE"
id = "xxxx"
name = "xxx-api"
main = "worker.js"

compatibility_flags = [ "nodejs_compat" ]
compatibility_date = "2024-09-23"

[env.production]
compatibility_flags = ["nodejs_compat"]

[unsafe.metadata.observability]
enabled = true

[[hyperdrive]]
binding = "HYPERDRIVE"
id = "xxxx"
How can I fix this?
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server