Summary
The patch release 12.0.1 → 12.0.2 bumped the archiver dependency from ^7 to ^8.0.0. archiver@8.0.0 is an ESM-only major release ("type": "module", single "exports": "./index.js" with no require condition, CJS build dropped).
testcontainers is itself compiled to CommonJS and consumes archiver via require("archiver"). require()-ing an ESM-only package is not supported by Jest's CommonJS module runtime, so any consumer running testcontainers under Jest now fails to even load the module.
Introducing an ESM-only major of a dependency is a breaking change for CommonJS consumers and shouldn't ship in a patch release. Jest's runtime does not honor Node's require(esm) interop, so this breaks Jest test suites that use testcontainers — independent of Node version.
Reproduction
repro fails at module load time (require("testcontainers") → require("archiver")), before any container is created.
package.json
{
"name": "tc-esm-repro",
"devDependencies": {
"jest": "30.4.2",
"testcontainers": "12.0.2"
}
}
repro.test.js
// Fails to even load the module — no Docker required.
require("testcontainers");
test("testcontainers loads under Jest", () => {});
Run:
Result:
SyntaxError: Cannot use import statement outside a module
.../node_modules/archiver/index.js:1
import Archiver from "./lib/core.js";
^^^^^^
at .../testcontainers/build/generic-container/started-generic-container.js:7
Changing only "testcontainers": "12.0.2" → "12.0.1" and re-running npx jest makes the suite pass. The sole difference is archiver@8 (ESM-only) vs archiver@7 (CJS).
Environment
testcontainers: 12.0.2
archiver: 8.0.0 (ESM-only)
- Jest: 30.4.2
- node: 24.16.0
Suggested resolution
- Revert to
archiver@^7 in a 12.0.x patch and ship the archiver@8 upgrade as a minor or major instead
Extra information
Issue report generated with assistance from Claude.
Summary
The patch release
12.0.1→12.0.2bumped thearchiverdependency from^7to^8.0.0.archiver@8.0.0is an ESM-only major release ("type": "module", single"exports": "./index.js"with norequirecondition, CJS build dropped).testcontainersis itself compiled to CommonJS and consumes archiver viarequire("archiver").require()-ing an ESM-only package is not supported by Jest's CommonJS module runtime, so any consumer running testcontainers under Jest now fails to even load the module.Introducing an ESM-only major of a dependency is a breaking change for CommonJS consumers and shouldn't ship in a patch release. Jest's runtime does not honor Node's
require(esm)interop, so this breaks Jest test suites that use testcontainers — independent of Node version.Reproduction
repro fails at module load time (
require("testcontainers")→require("archiver")), before any container is created.package.json{ "name": "tc-esm-repro", "devDependencies": { "jest": "30.4.2", "testcontainers": "12.0.2" } }repro.test.jsRun:
Result:
Changing only
"testcontainers": "12.0.2"→"12.0.1"and re-runningnpx jestmakes the suite pass. The sole difference isarchiver@8(ESM-only) vsarchiver@7(CJS).Environment
testcontainers: 12.0.2archiver: 8.0.0 (ESM-only)Suggested resolution
archiver@^7in a12.0.xpatch and ship thearchiver@8upgrade as a minor or major insteadExtra information
Issue report generated with assistance from Claude.