Registry / testing / babel-plugin-captains-log

babel-plugin-captains-log

JSON →
library1.3.2jsnpmunverified

A Babel plugin (v1.3.2, last updated July 2020, no recent releases) that automatically injects file name, line/column position, and variable name labels into console.log and other console method calls. Unlike manual logging wrappers, it works at the AST level during build time, supports ignore patterns, custom logger names, and selective method targeting. Requires Babel v6, ESM/CJS compatible, used as a development transform to enhance debugging output in bundled code.

npm install babel-plugin-captains-log
INSTALL
IMPORT
SIG · BABEL-PLUGIN-CAPTA
B
babel-plugin-captains-log
testingjavascriptv1.3.2
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
module.exports = require('babel-plugin-captains-log')
import plugin from 'babel-plugin-captains-log'
CJS-only package; use require in .babelrc or programmatic Babel config. No ESM wrapper provided.

Demonstrates plugin setup in .babelrc, default transformation adding file location and variable name, and all available options.

// .babelrc { "plugins": ["babel-plugin-captains-log"] } // Before transformation let x = 5; console.log(x); // After transformation (output during development) let x = 5; console.log("input.js(3:0)", "x", x); // With options { "plugins": [ ["babel-plugin-captains-log", { "methods": ["debug", "info"], "ignorePatterns": ["node_modules", "*.spec.js"], "loggerName": "myLogger", "injectVariableName": true, "injectFileName": true }] ] }
Debug
Known issues
breakingRequires Babel v6, not v7+
fix
Use @babel/plugin prefix or consider alternatives for Babel 7, e.g., babel-plugin-transform-console-log or custom build.
affects: all
gotchaPlugin mutates console statements globally; logged variable name may show original variable name even after minification if source maps enabled
fix
Disable injectVariableName in production build or use plugin only in development mode.
affects: all
deprecatedNo updates since July 2020; repository may be unmaintained
fix
Consider actively maintained alternatives like babel-plugin-transform-console-log, or fork the repository.
affects: >=1.3.0
Errors
Common errors & fixes
Error: Cannot find module 'babel-plugin-captains-log'
Plugin not installed or Babel not configured to resolve node_modules
fix
npm install --save-dev babel-plugin-captains-log
SyntaxError: Unexpected token (3:0)
Plugin transforms code but Babel version does not support the output syntax (e.g., arrow functions in older environments)
fix
Ensure Babel presets or plugins (e.g., @babel/preset-env) are configured to transpile the output.
TypeError: Cannot read property 'scope' of undefined
Using plugin with Babel 7 which has different visitor API
fix
Upgrade to a Babel 7 compatible plugin or downgrade to Babel 6.
Upgrade
Version history
1.3.2latest on npm
Audit
Dependencies
@babel/corerequiredPeer dependency for Babel plugin compatibility
Agent activity
30 hits · last 30 days
node
24
OpenAI (training)
1
Resources
babel-plugin-captains-log — npm install babel-plugin-captains-log · libregistry