Skip to content
Latchkey

Node "ExperimentalWarning: --loader is deprecated" in CI - Switch to --import

Newer Node deprecated the --loader flag in favor of --import with module.register. The warning is noisy now and the flag will break on a future Node.

What this error means

A CI step that registers a loader (for TypeScript or ESM transforms) prints ExperimentalWarning: --loader is deprecated, and may fail if warnings are treated as errors.

node
(node:1234) ExperimentalWarning: --loader is deprecated, use register()
or --import instead
(Use `node --trace-warnings ...` to show where the warning was created)

Common causes

Using the deprecated --loader flag

The command registers a loader with --loader, which newer Node deprecates in favor of module.register.

An outdated tool wrapper still passing --loader

A devDependency wrapper invokes Node with --loader under the hood.

How to fix it

Register the loader via --import

  1. Create a small register module that calls module.register with your loader.
  2. Pass it to Node with --import instead of --loader.
register.mjs
// register.mjs
import { register } from 'node:module';
register('./my-loader.mjs', import.meta.url);

Upgrade the tool that injects --loader

  1. Update the tool to a version that uses --import or register.
  2. Re-run so the deprecated flag is gone.

How to prevent it

  • Move loader registration to --import with module.register, keep loader-using tools current, and avoid relying on flags Node has marked deprecated.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →