Registry / web-framework / babel-preset-current-node-syntax

babel-preset-current-node-syntax

JSON →
library1.2.0jsnpmunverified

A Babel preset that automatically enables parsing support for all ECMAScript proposals and syntax features that are currently supported by the active Node.js version. Version 1.2.0 is the latest stable release, updated periodically to align with Node.js release cycles. This preset simplifies configuration by detecting the Node.js version at runtime and applying the appropriate Babel parser plugins, eliminating the need to manually specify plugins for each new syntax feature. It is designed for use with @babel/core v7 or v8 and is specifically tailored for projects targeting the local Node.js environment, such as tools, scripts, or libraries that rely on the latest syntax without transpilation. Key differentiators include zero configuration, automatic updates with Node.js versions, and support for features like import attributes and top-level await.

npm install babel-preset-current-node-syntax
INSTALL
IMPORT
SIG · BABEL-PRESET-CURRE
B
babel-preset-current-node-syntax
web-frameworkjavascriptv1.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default export
module.exports = require('babel-preset-current-node-syntax')
import preset from 'babel-preset-current-node-syntax'
This package is CJS-only; default import using ESM syntax will fail. Use require or set NODE_OPTIONS=--experimental-require-module in Node 22+.
preset in babel.config.js
module.exports = { presets: ['babel-preset-current-node-syntax'] }
module.exports = { presets: ['@babel/preset-current-node-syntax'] }
The package name does not include the @babel scope; using an incorrect scope will cause 'Module not found' errors.
with options (no options supported)
module.exports = { presets: [['babel-preset-current-node-syntax', {}]] }
module.exports = { presets: [['babel-preset-current-node-syntax', { modules: false }]] }
This preset accepts no options; passing unsupported options is silently ignored but may cause confusion.

Shows minimal setup to transpile modern Node.js syntax without manual plugin configuration using the preset.

// Install: npm install --save-dev babel-preset-current-node-syntax @babel/core // babel.config.js module.exports = { presets: ['babel-preset-current-node-syntax'] }; // Example input (index.js): import { fetch } from 'node:module'; const data = await fetch('https://example.com'); // Run: npx babel index.js --out-file output.js // Output will be identical to input if current Node.js supports the syntax. console.log('Transpilation complete with automatic syntax detection.');
Debug
Known issues
gotchaPreset does not support any options; passing configuration options will be silently ignored.
fix
Remove any options passed to the preset array.
affects: >=1.0.0
gotchaPreset is CJS-only; ESM-style default import (import preset from '...') fails in Node <22 with ESM.
fix
Use require() or set NODE_OPTIONS='--experimental-require-module' in Node 22+.
affects: <2.0.0
gotchaPreset only affects parsing, not transformation; output retains original syntax. Not suitable for targeting older Node versions.
fix
Use @babel/preset-env with targets set to older Node versions if transpilation is needed for compatibility.
affects: >0.0.0
gotchaPreset is designed for local Node.js version; using it in CI with a different Node version may produce different output.
fix
Ensure consistent Node version across environments or use a fixed preset (e.g., @babel/preset-env with specified targets).
affects: >0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'babel-preset-current-node-syntax'
Package not installed or incorrectly required.
fix
Install the preset as a dev dependency: npm install --save-dev babel-preset-current-node-syntax
Error: Plugin/Preset files are not allowed to export objects, only functions.
Using an ESM import to load the CJS preset.
fix
Use require() in babel.config.js or ensure babel is configured to handle CJS modules.
SyntaxError: Unexpected token 'import'
Preset not applied or Babel not configured to use the preset.
fix
Add 'babel-preset-current-node-syntax' to the presets array in babel.config.js and run Babel with --presets flag if using CLI.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
@babel/corerequiredPeer dependency required to function as a Babel preset.
Agent activity
7 hits · last 30 days
node
6
OpenAI (training)
1
Resources
babel-preset-current-node-syntax — npm install babel-preset-current-node-syntax · libregistry