Bug
docker/healthcheck.js uses CommonJS require(), but package.json declares "type": "module", which makes all .js files ES modules. Node.js rejects the file at runtime:
ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension
and '/app/package.json' contains "type": "module".
Impact
The Docker HEALTHCHECK fails on every check interval, so the container immediately enters the unhealthy state and never recovers. This has a critical downstream effect on Traefik v3: Traefik's Docker provider explicitly filters out unhealthy or starting containers and does not generate routes for them. The result is that the container runs fine internally but Traefik never routes traffic to it — 404 on every request from the outside even when traefik.enable=true is set.
Workaround (required to use with Traefik v3):
docker run --no-healthcheck ...
Steps to reproduce
- Run the image with default settings (no
--no-healthcheck):
docker run -d ghcr.io/alexandrecamillo/markup:latest
- After the
startPeriod (10 s), check health:
docker inspect markup --format '{{.State.Health.Status}}'
# → unhealthy
docker inspect markup --format '{{range .State.Health.Log}}{{.Output}}{{end}}'
# → ReferenceError: require is not defined in ES module scope ...
Fix
Two options:
Option A — rename the file to use the .cjs extension so Node.js treats it as CommonJS:
docker/healthcheck.js → docker/healthcheck.cjs
Update the HEALTHCHECK instruction in Dockerfile accordingly.
Option B — rewrite healthcheck.js using ES module syntax:
import http from 'node:http';
// ... rest of the healthcheck logic
Either fix removes the need for --no-healthcheck and restores proper health reporting + Traefik compatibility.
Environment
- Image:
ghcr.io/alexandrecamillo/markup:latest (built 2026-05-09)
- Node.js: v22.22.2
- Traefik: v3.7.0 (Docker provider,
network_mode: host)
Bug
docker/healthcheck.jsuses CommonJSrequire(), butpackage.jsondeclares"type": "module", which makes all.jsfiles ES modules. Node.js rejects the file at runtime:Impact
The Docker HEALTHCHECK fails on every check interval, so the container immediately enters the
unhealthystate and never recovers. This has a critical downstream effect on Traefik v3: Traefik's Docker provider explicitly filters outunhealthyorstartingcontainers and does not generate routes for them. The result is that the container runs fine internally but Traefik never routes traffic to it —404on every request from the outside even whentraefik.enable=trueis set.Workaround (required to use with Traefik v3):
Steps to reproduce
--no-healthcheck):startPeriod(10 s), check health:Fix
Two options:
Option A — rename the file to use the
.cjsextension so Node.js treats it as CommonJS:Update the
HEALTHCHECKinstruction inDockerfileaccordingly.Option B — rewrite
healthcheck.jsusing ES module syntax:Either fix removes the need for
--no-healthcheckand restores proper health reporting + Traefik compatibility.Environment
ghcr.io/alexandrecamillo/markup:latest(built 2026-05-09)network_mode: host)