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
- Create a small register module that calls module.register with your loader.
- 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
- 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.
Related guides
Node --experimental-vm-modules Required for ESM Tests in CI - Enable the FlagFix Jest ESM failures in CI that demand node --experimental-vm-modules by enabling the flag through NODE_OPTI…
Node DeprecationWarning Treated as Error in CI - Stop the Failing WarningFix CI jobs failing on a Node.js DeprecationWarning by replacing the deprecated API or removing the --throw-d…
Node "bad option" Unknown Flag in CI - Fix the Node InvocationFix the Node.js "bad option" unknown-flag error in CI by removing the flag, fixing its spelling, or using a N…