yarn test # from the repo root: builds the package, then runs node:test
yarn test:only # skip the rebuild when dist/ is freshSuites (all import the built artifact — expo-cloudflared / expo-cloudflared/internal):
options.test.mjs— option/env resolution matrix (modes, precedence, Expo's*.exp.directhostname ignored, conflicts, metrics)args.test.mjs— exact cloudflared argv per mode (global flags betweentunnelandrun)parser.test.mjs— real captured cloudflared log lines + chunk-split line reassemblytunnel.test.mjs— TunnelManager lifecycle with a fake spawn (kill-while-pending,closedsuppression on deliberate stop, crash emission, dedupe)api.test.mjs— the exact Expo CLI access pattern (require()+.connect/.kill?.()) and the 4.x version guardrail
The demo app installs the local build at node_modules/@expo/ngrok via
"@expo/ngrok": "portal:../../package". Remember: restart expo start after
rebuilding the package (Expo caches the resolved module per process).
yarn demo:tunnel(first run: watch the cloudflared binary download lazily — no postinstall).- Expo prints
Tunnel ready.and a QR code;[expo-cloudflared] Tunnel URL: https://*.trycloudflare.comappears. - Open the app via the QR in Expo Go / dev-client over the tunnel.
curl <tunnel-url>returns the dev-server response.- Restart
expo start --tunnel— no red "Tunnel connection has been closed" banner (Expo kills the tunnel before each attempt; we must not report that asclosed). kill -9 $(pgrep -x cloudflared)mid-session — Expo prints the closed error once; restarting works.- Ctrl-C Expo —
pgrep -x cloudflaredprints nothing (no orphans).
npx expo-cloudflared setup— wizard: login → create → route dns → prints env vars.- Copy
.env.local.example→.env.local, fillCLOUDFLARED_TUNNEL_NAME+CLOUDFLARED_TUNNEL_HOSTNAME;yarn demo:tunnelserves athttps://<hostname>every session. - Token mode: set
CLOUDFLARED_TUNNEL_TOKEN(+ hostname) instead; verify the dashboard ingress warning mentions the dev-server port. - Temporarily move
~/.cloudflared/cert.pemaway — name mode fails with the actionableERR_CERT_MISSINGmessage.
- Offline first run (no binary cached):
connect()fails withERR_BINARY_INSTALLpointing atnpx expo-cloudflared install. - Offline with binary cached: quick tunnel fails with
ERR_TUNNEL_START(cloudflared can't reach trycloudflare).
npx expo-cloudflared install | version | tunnel 8081 | setupall work fromtest/demo-app.