Lesson 14 / 31
Targeting Node.js Versions
Configure transpilation for Node.js by setting the minimum Node version so only unsupported syntax is converted.
Node 16+ supports most ES2021 features
Modern Node.js versions (16+, 18+, 20+) support async/await, const, arrow functions, destructuring, and more natively. You often don't need transpilation at all.
Node target configuration
Set targets.node to specify minimum Node version. Babel then transpiles only incompatible features.
// Target Node 18+: minimal transpilation
{
"presets": [
["@babel/preset-env", { "targets": { "node": "18" } }]
]
}
// Target Node 12: more transpilation
{
"presets": [
["@babel/preset-env", { "targets": { "node": "12" } }]
]
}Modern Node backends rarely need Babel
If your backend runs Node 18+, consider skipping Babel entirely and using TypeScript for type checking only. Faster builds, simpler setup.