winstonjs/winston · error · Error
Logger.cli() was removed in winston@3.0.0 Use a custom winst
Error message
Logger.cli() was removed in winston@3.0.0 Use a custom winston.formats.cli() instead. See: https://github.com/winstonjs/winston/tree/master/UPGRADE-3.0.md
What it means
`Logger.prototype.cli()` was a winston 2.x convenience that switched the logger to CLI-style output formatting. It was removed in the 3.0.0 rewrite, and the method is kept only to throw a migration notice pointing at `winston.formats.cli()` (the format combinator) and the UPGRADE-3.0.md guide.
Source
Thrown at lib/winston/logger.js:638
/**
* Backwards compatibility to `exceptions.handle` in winston < 3.0.0.
* @returns {undefined}
* @deprecated
*/
unhandleExceptions(...args) {
// eslint-disable-next-line no-console
console.warn(
'Deprecated: .unhandleExceptions() will be removed in winston@4. Use .exceptions.unhandle()'
);
this.exceptions.unhandle(...args);
}
/**
* Throw a more meaningful deprecation notice
* @throws {Error} - TODO: add throws description.
*/
cli() {
throw new Error(
[
'Logger.cli() was removed in winston@3.0.0',
'Use a custom winston.formats.cli() instead.',
'See: https://github.com/winstonjs/winston/tree/master/UPGRADE-3.0.md'
].join('\n')
);
}
/**
* Bubbles the `event` that occured on the specified `transport` up
* from this instance.
* @param {string} event - The event that occured
* @param {Object} transport - Transport on which the event occured
* @private
*/
_onEvent(event, transport) {
function transportEvent(err) {
// https://github.com/winstonjs/winston/issues/1364View on GitHub (pinned to ff0b79de85)
Solutions
- Remove the `logger.cli()` call.
- Use the CLI format instead: add `winston.format.cli()` to the logger's `format` combine chain.
- If CLI coloring/levels behavior is wanted, combine `format.colorize()`, `format.padLevels()`, `format.errors()`, `format.cli()` as needed.
- Follow UPGRADE-3.0.md section on CLI output.
Example fix
// before (winston 2.x)
const logger = new winston.Logger();
logger.cli();
// after (winston 3.x)
const logger = winston.createLogger({
format: winston.format.cli(),
transports: [new winston.transports.Console()]
}); Defensive patterns
Strategy: validation
Validate before calling
if (typeof logger.cli === 'function') {
try { logger.cli; } finally { /* cli() always throws on winston 3 — remove the call */ }
} Type guard
function supportsCli(x) { return typeof x.cli === 'function' && x.constructor && !/removed/.test(x.cli.toString()); } Try / catch
try {
logger.cli();
} catch (err) {
if (err.message.includes('Logger.cli() was removed')) {
logger.configure({ format: winston.format.cli() });
} else { throw err; }
} Prevention
- Remove cli() calls when bumping to winston 3 — it always throws
- Use `format.cli()` in the format chain instead
- Add a startup smoke test that builds the logger with intended format
- Scan codebase for `\.cli()` during dependency upgrades
When it happens
Trigger: Calling `logger.cli()` (or `winston.cli()`) on any winston 3 logger instance — always throws, no conditions.
Common situations: Running winston 2.x-era code on winston 3; tutorials showing `winston.cli()`; automated migrations that preserved old method calls.
Related errors
- { %s } was removed in winston@3.0.0. Use a custom winston.fo
- { %s } was removed in winston@3.0.0.
- { colors, emitErrs, formatters, padLevels, rewriters, stripC
- Callback function no longer supported as of winston@3.0.0
- Deprecated: .handleExceptions() will be removed in winston@4
AI-assisted analysis of winstonjs/winston@ff0b79de85 (2026-08-31).
Data as JSON: /api/errors/579f28537d88ad32.
Report an issue: GitHub.