All automatic worker deploys through github are failing, but succeeding when run manually

I've set up automatic deployment on pushes to our main branch, but whenever I push to main I get the following build error listing all of my dependencies:
Initializing build environment...
Success: Finished initializing build environment
Cloning repository...
Detected the following tools from environment: [email protected], [email protected]
Installing project dependencies: bun install --frozen-lockfile
bun install v1.1.33 (247456b6)
Resolving dependencies
Resolved, downloaded and extracted [2]

+ @cloudflare/[email protected]

101 packages installed [2.96s]
Executing user deploy command: npx wrangler deploy

⛅️ wrangler 3.83.0
-------------------


✘ [ERROR] Build failed with 165 errors:

✘ [ERROR] Could not resolve "posthog-node"

../components/tracking/posthog/PostHogClient.ts:3:24:
3 │ import { PostHog } from "posthog-node";
╵ ~~~~~~~~~~~~~~

You can mark the path "posthog-node" as external to exclude it from the bundle, which will remove this error.


✘ [ERROR] Could not resolve "react"

../components/ui/use-toast.ts:2:18:
2 │ import React from "react";
╵ ~~~~~~~

You can mark the path "react" as external to exclude it from the bundle, which will remove this error.


✘ [ERROR] Could not resolve "zod"

../core/inputs.ts:4:18:
4 │ import { z } from "zod";
╵ ~~~~~

You can mark the path "zod" as external to exclude it from the bundle, which will remove this error.

... (continues with 162 other dependency errors)...
Initializing build environment...
Success: Finished initializing build environment
Cloning repository...
Detected the following tools from environment: [email protected], [email protected]
Installing project dependencies: bun install --frozen-lockfile
bun install v1.1.33 (247456b6)
Resolving dependencies
Resolved, downloaded and extracted [2]

+ @cloudflare/[email protected]

101 packages installed [2.96s]
Executing user deploy command: npx wrangler deploy

⛅️ wrangler 3.83.0
-------------------


✘ [ERROR] Build failed with 165 errors:

✘ [ERROR] Could not resolve "posthog-node"

../components/tracking/posthog/PostHogClient.ts:3:24:
3 │ import { PostHog } from "posthog-node";
╵ ~~~~~~~~~~~~~~

You can mark the path "posthog-node" as external to exclude it from the bundle, which will remove this error.


✘ [ERROR] Could not resolve "react"

../components/ui/use-toast.ts:2:18:
2 │ import React from "react";
╵ ~~~~~~~

You can mark the path "react" as external to exclude it from the bundle, which will remove this error.


✘ [ERROR] Could not resolve "zod"

../core/inputs.ts:4:18:
4 │ import { z } from "zod";
╵ ~~~~~

You can mark the path "zod" as external to exclude it from the bundle, which will remove this error.

... (continues with 162 other dependency errors)...
If I then go to the deployments page and deploy manually, the deployment works just fine. Is this a mistake I made somewhere or an issue with the deployment system?
1 Reply
Maximo
Maximo2mo ago
@Tal (Wordware) Does your package.json contain posthog-node, react and zod?
Want results from more Discord servers?
Add your server