Skip to content

fix: upgrade posthog-node to v5 to fix Worker axios bundling failure#128

Merged
TheMeinerLP merged 1 commit into
mainfrom
claude/posthog-node-v5
May 15, 2026
Merged

fix: upgrade posthog-node to v5 to fix Worker axios bundling failure#128
TheMeinerLP merged 1 commit into
mainfrom
claude/posthog-node-v5

Conversation

@TheMeinerLP
Copy link
Copy Markdown
Collaborator

Summary

The cloudflare_module Worker deploy ("Workers Builds: launchpad") keeps failing with:

✘ [ERROR] Could not resolve "axios"
  .output/server/chunks/build/server.mjs: ...if(!cw){const e=require("axios");...

Root cause: posthog-node v4 (pulled in transitively by nuxt-posthog) does a dynamic require("axios"). Nitro/Rollup cannot statically inline a runtime require, so it stays as an external require in server.mjs, and wrangler's esbuild can't resolve it (no node_modules in .output). The earlier externals.inline hack from #126 did not work for exactly this reason.

posthog-node v5 dropped axios entirely and uses native fetch (Workers-native), eliminating the require.

Changes

  • pnpm-workspace.yaml: pin posthog-node to ^5.8.4 via override (it is transitive via nuxt-posthog@1.6.3; resolves to 5.34.2).
  • nuxt.config.ts: revert the now-useless externals.inline: ["axios"] back to ["@nuxt/content"].
  • pnpm-lock.yaml: regenerated.

Compatibility

nuxt-posthog@1.6.3's server plugin only uses new PostHog(key, { host }), reloadFeatureFlags() and getAllFlagsAndPayloads() — all unchanged in posthog-node v5. The remaining axios in the lockfile comes only from the wait-on devDependency and is never bundled into the server.

Test plan

  • "Workers Builds: launchpad" deploy completes without Could not resolve "axios"
  • Server-side PostHog feature flags still resolve (SSR)
  • Site renders correctly

https://claude.ai/code/session_012YWscdohmouZHhZ7otKnqh


Generated by Claude Code

The cloudflare_module Worker deploy kept failing with
`Could not resolve "axios"`: posthog-node v4 (pulled in transitively by
nuxt-posthog) does a dynamic require("axios") that Nitro leaves as an
unresolvable external in server.mjs. The earlier externals.inline hack
did not work because it is a runtime require.

posthog-node v5 dropped axios entirely (uses native fetch, which is
Workers-native). Pin it via a pnpm override; nuxt-posthog's server
usage (new PostHog/reloadFeatureFlags/getAllFlagsAndPayloads) is
unchanged in v5. Also revert the now-useless externals.inline axios
entry. Remaining axios in the lockfile is only via the wait-on
devDependency and is never bundled into the server.

https://claude.ai/code/session_012YWscdohmouZHhZ7otKnqh
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying launchpad with  Cloudflare Pages  Cloudflare Pages

Latest commit: fd689e4
Status:🚫  Build failed.

View logs

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
launchpad fd689e4 Commit Preview URL

Branch Preview URL
May 15 2026, 09:16 PM

@TheMeinerLP TheMeinerLP merged commit 53b1be3 into main May 15, 2026
4 of 5 checks passed
@TheMeinerLP TheMeinerLP deleted the claude/posthog-node-v5 branch May 15, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants