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: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
- Create a small register module that calls module.register with your loader.
- Pass it to Node with --import instead of --loader.
// register.mjs
import { register } from 'node:module';
register('./my-loader.mjs', import.meta.url);Upgrade the tool that injects --loader
- Update the tool to a version that uses --import or register.
- 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.