{"id":19270,"library":"babel-preset-current-node-syntax","title":"babel-preset-current-node-syntax","description":"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.","status":"active","version":"1.2.0","language":"javascript","source_language":"en","source_url":"https://github.com/nicolo-ribaudo/babel-preset-current-node-syntax","tags":["javascript"],"install":[{"cmd":"npm install babel-preset-current-node-syntax","lang":"bash","label":"npm"},{"cmd":"yarn add babel-preset-current-node-syntax","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-preset-current-node-syntax","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required to function as a Babel preset.","package":"@babel/core","optional":false}],"imports":[{"note":"This package is CJS-only; default import using ESM syntax will fail. Use require or set NODE_OPTIONS=--experimental-require-module in Node 22+.","wrong":"import preset from 'babel-preset-current-node-syntax'","symbol":"default export","correct":"module.exports = require('babel-preset-current-node-syntax')"},{"note":"The package name does not include the @babel scope; using an incorrect scope will cause 'Module not found' errors.","wrong":"module.exports = { presets: ['@babel/preset-current-node-syntax'] }","symbol":"preset in babel.config.js","correct":"module.exports = { presets: ['babel-preset-current-node-syntax'] }"},{"note":"This preset accepts no options; passing unsupported options is silently ignored but may cause confusion.","wrong":"module.exports = { presets: [['babel-preset-current-node-syntax', { modules: false }]] }","symbol":"with options (no options supported)","correct":"module.exports = { presets: [['babel-preset-current-node-syntax', {}]] }"}],"quickstart":{"code":"// Install: npm install --save-dev babel-preset-current-node-syntax @babel/core\n// babel.config.js\nmodule.exports = {\n  presets: ['babel-preset-current-node-syntax']\n};\n// Example input (index.js):\nimport { fetch } from 'node:module';\nconst data = await fetch('https://example.com');\n// Run: npx babel index.js --out-file output.js\n// Output will be identical to input if current Node.js supports the syntax.\nconsole.log('Transpilation complete with automatic syntax detection.');","lang":"javascript","description":"Shows minimal setup to transpile modern Node.js syntax without manual plugin configuration using the preset."},"warnings":[{"fix":"Remove any options passed to the preset array.","message":"Preset does not support any options; passing configuration options will be silently ignored.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use require() or set NODE_OPTIONS='--experimental-require-module' in Node 22+.","message":"Preset is CJS-only; ESM-style default import (import preset from '...') fails in Node <22 with ESM.","severity":"gotcha","affected_versions":"<2.0.0"},{"fix":"Use @babel/preset-env with targets set to older Node versions if transpilation is needed for compatibility.","message":"Preset only affects parsing, not transformation; output retains original syntax. Not suitable for targeting older Node versions.","severity":"gotcha","affected_versions":">0.0.0"},{"fix":"Ensure consistent Node version across environments or use a fixed preset (e.g., @babel/preset-env with specified targets).","message":"Preset is designed for local Node.js version; using it in CI with a different Node version may produce different output.","severity":"gotcha","affected_versions":">0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Install the preset as a dev dependency: npm install --save-dev babel-preset-current-node-syntax","cause":"Package not installed or incorrectly required.","error":"Error: Cannot find module 'babel-preset-current-node-syntax'"},{"fix":"Use require() in babel.config.js or ensure babel is configured to handle CJS modules.","cause":"Using an ESM import to load the CJS preset.","error":"Error: Plugin/Preset files are not allowed to export objects, only functions."},{"fix":"Add 'babel-preset-current-node-syntax' to the presets array in babel.config.js and run Babel with --presets flag if using CLI.","cause":"Preset not applied or Babel not configured to use the preset.","error":"SyntaxError: Unexpected token 'import'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}