Can't build and deploy to workers

I’m trying to build and deploy this: GitHub - portunus-dev/portunus-worker: edge workers as API servers

with wrangler with the following wrangler.toml

name = "portunus-worker"
account_id = "2d094cassssssssssssssss0ce09f"
workers_dev = true
main = "index.js"

compatibility_date = "2022-07-12"
node_compat = true

#compatibility_flags = [ "nodejs_compat" ]

[build]
command = "npm install and npm run build"


[env.production]
route = "api.example.com/*"
kv_namespaces = [
    # id = The ID of the KV namespace.
    { binding = "KV", id = "08e5848ddddddddddd44d7a312beee" },
    { binding = "USERS", id = "0d9997ddddddddd18d2f6f89680e" }
]

But when I’m running with node_compact=true, I’m getting this error:


which gives error for deta-worker package but I checked the package repo and it is written in cf worker support format: GitHub - woozyking/deta-worker at 0.2-with-tests

but when I’m switching to compatibility_flags = [ "nodejs_compat" ], I’m getting this error:

And my wrangler cli version is 3.2.0

I’m not sure why there is different behaviour for similar flags but as far as I know compatibility_flags = [ "nodejs_compat" ] new.

When using node_compat=true, It does throw an error for the deta-worker package but when I switch it to compatibility_flags = [ "nodejs_compat" ] it throws all different kinds of the package wasn’t found errors, my guess is it is because of the list provided here: Node.js Compatibility · Cloudflare Workers docs

But a contradictory statement here is why this is not the case with node_compat=true (considering it is still working for backward compatibility).

I would appreciate any help.

Hello @ashishjullia19

The errors you’re encountering seems to be due to your version of Wrangler. You can find a detailed in the Cloudflare documentation.

Through our Discord channel, you can now connect with the team to ask questions, show off what you’re building, and discuss the platform with other developers.

The Cloudflare Workers team has his own Discord channel! You can join right away by going here.

Hope this helps!

2 Likes

Thanks I’m able to deploy this, the problem was with the mismatch b/w commonJS and ES6 syntax, so I used webpack.

1 Like