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
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
babelPluginUndebug
✓ import babelPluginUndebug from 'babel-plugin-undebug'
✗ import { babelPluginUndebug } from 'babel-plugin-undebug'
Default export only; named export does not exist. ESM-only since v2.
babelPluginUndebug
✓ module.exports = { plugins: [['babel-plugin-undebug', options]] }
✗ const babelPluginUndebug = require('babel-plugin-undebug')
CJS require is not supported in v3 (ESM-only). Use dynamic import or configure via babel config file.
babel-plugin-undebug
✓ plugins: ['babel-plugin-undebug']
✗ plugins: ['undebug']
Babel plugin name must be the full npm package name when using string shorthand. Version mismatch can cause undefined plugin errors.
Demonstrates installing, configuring, and running babel-plugin-undebug to strip debug calls from a Node.js script, preserving other statements.
// Install: npm install --save-dev babel-plugin-undebug @babel/core @babel/cli
// babel.config.json
{
"plugins": ["babel-plugin-undebug"]
}
// example.js
const debug = require('debug')('myapp');
let count = 0;
debug('Count is %d', count++);
count++;
debug('Now count is %d', count);
console.log('Final', count);
// Run: npx babel example.js --out-file output.js
// output.js:
// let count = 0;
// count++;
// console.log('Final', count);
debug('Unreachable after removal');
Errors
Common errors & fixes
Error: Cannot find module 'babel-plugin-undebug'
Package not installed or named incorrectly in Babel config
fixRun `npm install --save-dev babel-plugin-undebug` and ensure plugins array uses full name: 'babel-plugin-undebug'
Error [ERR_REQUIRE_ESM]: require() of ES Module /node_modules/babel-plugin-undebug/index.js from ... not supported.
Using require() to load the plugin in a CommonJS context with v2/v3
fixUse ESM import, or switch to dynamic import(). If you need CJS, downgrade to v1.x.
TypeError: babelPluginUndebug is not a function
Attempting to use a named export instead of default export
fixChange import from `import { babelPluginUndebug }` to `import babelPluginUndebug` Audit
Dependencies
@babel/corerequiredRequired as a peer dependency to run as a Babel plugin