winstonjs/winston · error · Error

{ %s } was removed in winston@3.0.0.

Error message

{ %s } was removed in winston@3.0.0.

What it means

winston exposes a `deprecated(prop)` helper in lib/winston/common.js that returns a throwing function. When code calls a winston 2.x API property that was removed in the 3.0.0 rewrite (wired via `forFunctions`/`forProperties` onto exports like `winston.transports` or `winston.Logger` internals), the thrown Error is formatted as `{ <prop> } was removed in winston@3.0.0.` It exists to fail fast instead of silently no-op on removed APIs.

Source

Thrown at lib/winston/common.js:21

 *
 * (C) 2010 Charlie Robbins
 * MIT LICENCE
 */

'use strict';

const { format } = require('util');

/**
 * Set of simple deprecation notices and a way to expose them for a set of
 * properties.
 * @type {Object}
 * @private
 */
exports.warn = {
  deprecated(prop) {
    return () => {
      throw new Error(format('{ %s } was removed in winston@3.0.0.', prop));
    };
  },
  useFormat(prop) {
    return () => {
      throw new Error([
        format('{ %s } was removed in winston@3.0.0.', prop),
        'Use a custom winston.format = winston.format(function) instead.'
      ].join('\n'));
    };
  },
  forFunctions(obj, type, props) {
    props.forEach(prop => {
      obj[prop] = exports.warn[type](prop);
    });
  },
  forProperties(obj, type, props) {
    props.forEach(prop => {
      const notice = exports.warn[type](prop);

View on GitHub (pinned to ff0b79de85)

Solutions

  1. Read the message's `{ prop }` name and look up its winston 3 replacement in UPGRADE-3.0.md, then update the call site.
  2. Replace removed convenience APIs with the winston 3 equivalents: `winston.createLogger` + `format.*` combinators instead of formatters/rewriters, and `transports.*` classes instead of legacy helpers.
  3. Pin/upgrade any third-party package that depends on winston 2.x APIs to a winston-3-compatible version.
  4. As a stopgap, pin winston to ^2.4.x — but only for legacy apps that cannot be migrated yet.

Example fix

// before (winston 2.x)
winston.setLevels(winston.config.syslog.levels);

// after (winston 3.x)
const logger = winston.createLogger({
  levels: winston.config.syslog.levels,
  transports: [new winston.transports.Console()]
});
Defensive patterns

Strategy: validation

Validate before calling

const REMOVED_V2 = ['setLevels', 'addRewriter', 'addFormatter', 'cli', 'padLevels', 'clamp'];
if (REMOVED_V2.some(fn => typeof winston[fn] === 'function' && winston[fn].toString().includes('removed in winston@3'))) {
  throw new Error('winston 2.x API detected; migrate to winston 3 (see UPGRADE-3.0.md)');
}

Type guard

function isWinston3(w) { return typeof w.createLogger === 'function'; }

Try / catch

try {
  legacyWinstonCall();
} catch (err) {
  if (err.message.includes('was removed in winston@3.0.0')) {
    migrateToWinston3();
  } else { throw err; }
}

Prevention

When it happens

Trigger: Calling any winston 2.x-era function that was replaced in winston 3 and proxied through `warn.deprecated(prop)` — e.g. accessing removed helpers on the winston namespace or logger such as `winston.setLevels`, `winston.addColors`-style legacy shims, or other prop names registered with `deprecated()` in common.js.

Common situations: Upgrading an app from winston 2.x to 3.x without following UPGRADE-3.0.md; copy-pasted logging code from old tutorials or Stack Overflow answers; transitive dependencies still written against the winston 2.x API.

Related errors


AI-assisted analysis of winstonjs/winston@ff0b79de85 (2026-08-31). Data as JSON: /api/errors/0ddbaf07b2e6831c. Report an issue: GitHub.