URGENT! Deprecated: .handleExceptions() will be removed in winston@4. Use .exceptions.handle()

Hello everyone!

I am watching mastering React and in Calling Backend Services lecture, I am trying to do ‘node index.js’ however I ran into the below error. does anyone knows how to solve this issue? I spent hours and hours but still couldn’t fix.

Deprecated: .handleExceptions() will be removed in winston@4. Use .exceptions.handle()
{“date”:“Tue Oct 25 2022 16:08:11 GMT-0700 (Pacific Daylight Time)”,“error”:{},“exception”:true,“level”:“error”,“message”:“uncaughtException: Invalid transport, must be an object with a log method.\nError: Invalid transport, must be an object with a log method.\n at new LegacyTransportStream (C:\vidly-api-node\node_modules\winston-transport\legacy.js:18:11)\n at DerivedLogger.add (C:\vidly-api-node\node_modules\winston\lib\winston\logger.js:352:11)\n at Object.exports. [as add] (C:\vidly-api-node\node_modules\winston\lib\winston.js:105:68)\n at module.exports (C:\vidly-api-node\startup\logging.js:14:11)\n at Object. (C:\vidly-api-node\index.js:6:29)\n at Module._compile (node:internal/modules/cjs/loader:1126:14)\n at Object.Module._extensions…js (node:internal/modules/cjs/loader:1180:10)\n at Module.load (node:internal/modules/cjs/loader:1004:32)\n at Function.Module._load (node:internal/modules/cjs/loader:839:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)”,“os”:{“loadavg”:[0,0,0],“uptime”:13890},“process”:{“argv”:[“C:\Program Files\nodejs\node.exe”,“C:\vidly-api-node\index.js”],“cwd”:“C:\vidly-api-node”,“execPath”:“C:\Program Files\nodejs\node.exe”,“gid”:null,“memoryUsage”:{“arrayBuffers”:187200,“external”:1838541,“heapTotal”:17854464,“heapUsed”:10564656,“rss”:36831232},“pid”:17428,“uid”:null,“version”:“v16.17.0”},“stack”:“Error: Invalid transport, must be an object with a log method.\n at new LegacyTransportStream (C:\vidly-api-node\node_modules\winston-transport\legacy.js:18:11)\n at DerivedLogger.add (C:\vidly-api-node\node_modules\winston\lib\winston\logger.js:352:11)\n at Object.exports. [as add] (C:\vidly-api-node\node_modules\winston\lib\winston.js:105:68)\n at module.exports (C:\vidly-api-node\startup\logging.js:14:11)\n at Object. (C:\vidly-api-node\index.js:6:29)\n at Module._compile (node:internal/modules/cjs/loader:1126:14)\n at Object.Module._extensions…js (node:internal/modules/cjs/loader:1180:10)\n at Module.load (node:internal/modules/cjs/loader:1004:32)\n at Function.Module._load (node:internal/modules/cjs/loader:839:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)”,“trace”:[{“column”:11,“file”:“C:\vidly-api-node\node_modules\winston-transport\legacy.js”,“function”:“new LegacyTransportStream”,“line”:18,“method”:null,“native”:false},{“column”:11,“file”:“C:\vidly-api-node\node_modules\winston\lib\winston\logger.js”,“function”:“DerivedLogger.add”,“line”:352,“method”:“add”,“native”:false},{“column”:68,“file”:“C:\vidly-api-node\node_modules\winston\lib\winston.js”,“function”:“Object.exports. [as add]”,“line”:105,“method”:“ [as add]”,“native”:false},{“column”:11,“file”:“C:\vidly-api-node\startup\logging.js”,“function”:“module.exports”,“line”:14,“method”:“exports”,“native”:false},{“column”:29,“file”:“C:\vidly-api-node\index.js”,“function”:null,“line”:6,“method”:null,“native”:false},{“column”:14,“file”:“node:internal/modules/cjs/loader”,“function”:“Module._compile”,“line”:1126,“method”:“_compile”,“native”:false},{“column”:10,“file”:“node:internal/modules/cjs/loader”,“function”:“Module._extensions…js”,“line”:1180,“method”:“.js”,“native”:false},{“column”:32,“file”:“node:internal/modules/cjs/loader”,“function”:“Module.load”,“line”:1004,“method”:“load”,“native”:false},{“column”:12,“file”:“node:internal/modules/cjs/loader”,“function”:“Module._load”,“line”:839,“method”:“_load”,“native”:false},{“column”:12,“file”:“node:internal/modules/run_main”,“function”:“Function.executeUserEntryPoint [as runMain]”,“line”:81,“method”:“executeUserEntryPoint [as runMain]”,“native”:false}]}

Hi,

Is it in the context of the React course?

I think I met that but I am not sure.

Should it be related to the course, please tell me what lecture it is related to. I might lookup my notes or my code to see if there is anything.

Regards.

Hi.
yes this is the context of the Mastering React → Calling Backend Services → lecture number 20 - Setting Up the Node Backend

I appreciate your help

Thank you.
It is almost 3AM here so I’ll leave it for today.
I’ll check my notes ASAP when I have some free time and tell you if I find something.

Hi, just wanted to follow up and see if you found anything. thanks

Hi,

I did search my notes and code.
Nothing in my notes but there is a reference in the code base.

This line is in the provided Node back-end so I rather cannot help on that.

My guess though, interpreting the error message, is you shall replace winston.handleExceptions() with winston.exceptions.handle().

I might have met that message but likely , last time I used it, it wasn’t taken out yet. So I could still use the application.

Hopefully the change above would work.

Good Luck.

EDIT:
Vidly still starts on my side.

And it is fully functional. It is getting old so I get warning telling me I should update but it have served its purpose to me.

So you may have updated something in the back end part.

Compare packages.json to check if you have the same versions as I do, or adapt to the new ways as suggested above.

Vidly Back-End packages.json

{
  "name": "vidly",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "node index.js",
    "seed": "node seed.js",
    "test": "jest --watchAll --verbose"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bcrypt": "^5.0.0",
    "config": "^1.29.4",
    "cors": "^2.8.4",
    "express": "^4.16.2",
    "express-async-errors": "^2.1.0",
    "fawn": "^2.1.5",
    "jest-html-reporter": "^3.4.1",
    "joi": "^13.4.0",
    "joi-objectid": "^2.0.0",
    "jsonwebtoken": "^8.1.1",
    "lodash": "^4.17.21",
    "moment": "^2.20.1",
    "mongoose": "^5.12.14",
    "walker": "^1.0.7",
    "winston": "^2.4.0",
    "winston-mongodb": "^3.0.0"
  },
  "devDependencies": {
    "jest": "^22.2.2",
    "supertest": "^3.0.0"
  }
}

Does it happen at startup or in a specific scenario ?

Cheers

Hi,

Thank you for providing these details. I successfully replaced ‘winston.handleExceptions()’ with ‘winston.exceptions.handle()’ and the error message no longer appears, but the remainder of the message remains consistent. I also replaced your packages.json with mine, but I still get the problem shown below. Could you please take a look and see if this is an error you’ve seen before? I greatly appreciate your help.

C:\Users\Hamidreza\Downloads\Section 9- Authentication and Authorization\Section 9- Authentication and Authorization\start\vidly-api-node>node index.js
{“date”:“Wed Oct 26 2022 12:56:07 GMT-0700 (Pacific Daylight Time)”,“error”:{},“exception”:true,“level”:“error”,“message”:“uncaughtException: Invalid transport, must be an object with a log method.\nError: Invalid transport, must be an object with a log method.\n at new LegacyTransportStream (C:\Users\Hamidreza\Downloads\Section 9- Authentication and Authorization\Section 9- Authentication and Authorization\start\vidly-api-node\node_modules\winston-transport\legacy.js:18:11)\n at DerivedLogger.add (C:\Users\Hamidreza\Downloads\Section 9- Authentication and Authorization\Section 9- Authentication and Authorization\start\vidly-api-node\node_modules\winston\lib\winston\logger.js:352:11)\n at Object.exports. [as add] (C:\Users\Hamidreza\Downloads\Section 9- Authentication and Authorization\Section 9- Authentication and Authorization\start\vidly-api-node\node_modules\winston\lib\winston.js:105:68)\n at module.exports (C:\Users\Hamidreza\Downloads\Section 9- Authentication and Authorization\Section 9- Authentication and Authorization\start\vidly-api-node\startup\logging.js:14:11)\n at Object. (C:\Users\Hamidreza\Downloads\Section 9- Authentication and Authorization\Section 9- Authentication and Authorization\start\vidly-api-node\index.js:6:29)\n at Module._compile (node:internal/modules/cjs/loader:1126:14)\n at Object.Module._extensions…js (node:internal/modules/cjs/loader:1180:10)\n at Module.load (node:internal/modules/cjs/loader:1004:32)\n at Function.Module._load (node:internal/modules/cjs/loader:839:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)”,“os”:{“loadavg”:[0,0,0],“uptime”:88766},“process”:{“argv”:[“C:\Program Files\nodejs\node.exe”,“C:\Users\Hamidreza\Downloads\Section 9- Authentication and Authorization\Section 9- Authentication and Authorization\start\vidly-api-node\index.js”],“cwd”:“C:\Users\Hamidreza\Downloads\Section 9- Authentication and Authorization\Section 9- Authentication and Authorization\start\vidly-api-node”,“execPath”:“C:\Program Files\nodejs\node.exe”,“gid”:null,“memoryUsage”:{“arrayBuffers”:122858,“external”:1838541,“heapTotal”:18378752,“heapUsed”:11232784,“rss”:38678528},“pid”:24008,“uid”:null,“version”:“v16.17.0”},“stack”:“Error: Invalid transport, must be an object with a log method.\n at new LegacyTransportStream (C:\Users\Hamidreza\Downloads\Section 9- Authentication and Authorization\Section 9- Authentication and Authorization\start\vidly-api-node\node_modules\winston-transport\legacy.js:18:11)\n at DerivedLogger.add (C:\Users\Hamidreza\Downloads\Section 9- Authentication and Authorization\Section 9- Authentication and Authorization\start\vidly-api-node\node_modules\winston\lib\winston\logger.js:352:11)\n at Object.exports. [as add] (C:\Users\Hamidreza\Downloads\Section 9- Authentication and Authorization\Section 9- Authentication and Authorization\start\vidly-api-node\node_modules\winston\lib\winston.js:105:68)\n at module.exports (C:\Users\Hamidreza\Downloads\Section 9- Authentication and Authorization\Section 9- Authentication and Authorization\start\vidly-api-node\startup\logging.js:14:11)\n at Object. (C:\Users\Hamidreza\Downloads\Section 9- Authentication and Authorization\Section 9- Authentication and Authorization\start\vidly-api-node\index.js:6:29)\n at Module._compile (node:internal/modules/cjs/loader:1126:14)\n at Object.Module._extensions…js (node:internal/modules/cjs/loader:1180:10)\n at Module.load (node:internal/modules/cjs/loader:1004:32)\n at Function.Module._load (node:internal/modules/cjs/loader:839:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)”,“trace”:[{“column”:11,“file”:“C:\Users\Hamidreza\Downloads\Section 9- Authentication and Authorization\Section 9- Authentication and Authorization\start\vidly-api-node\node_modules\winston-transport\legacy.js”,“function”:“new LegacyTransportStream”,“line”:18,“method”:null,“native”:false},{“column”:11,“file”:“C:\Users\Hamidreza\Downloads\Section 9- Authentication and Authorization\Section 9- Authentication and Authorization\start\vidly-api-node\node_modules\winston\lib\winston\logger.js”,“function”:“DerivedLogger.add”,“line”:352,“method”:“add”,“native”:false},{“column”:68,“file”:“C:\Users\Hamidreza\Downloads\Section 9- Authentication and Authorization\Section 9- Authentication and Authorization\start\vidly-api-node\node_modules\winston\lib\winston.js”,“function”:“Object.exports. [as add]”,“line”:105,“method”:“ [as add]”,“native”:false},{“column”:11,“file”:“C:\Users\Hamidreza\Downloads\Section 9- Authentication and Authorization\Section 9- Authentication and Authorization\start\vidly-api-node\startup\logging.js”,“function”:“module.exports”,“line”:14,“method”:“exports”,“native”:false},{“column”:29,“file”:“C:\Users\Hamidreza\Downloads\Section 9- Authentication and Authorization\Section 9- Authentication and Authorization\start\vidly-api-node\index.js”,“function”:null,“line”:6,“method”:null,“native”:false},{“column”:14,“file”:“node:internal/modules/cjs/loader”,“function”:“Module._compile”,“line”:1126,“method”:“_compile”,“native”:false},{“column”:10,“file”:“node:internal/modules/cjs/loader”,“function”:“Module._extensions…js”,“line”:1180,“method”:“.js”,“native”:false},{“column”:32,“file”:“node:internal/modules/cjs/loader”,“function”:“Module.load”,“line”:1004,“method”:“load”,“native”:false},{“column”:12,“file”:“node:internal/modules/cjs/loader”,“function”:“Module._load”,“line”:839,“method”:“_load”,“native”:false},{“column”:12,“file”:“node:internal/modules/run_main”,“function”:“Function.executeUserEntryPoint [as runMain]”,“line”:81,“method”:“executeUserEntryPoint [as runMain]”,“native”:false}]}

Blockquote

Please note that I am trying to do the node index.js inside the folder: Section 9- Authentication and Authorization\start\vidly-api-node>node index.js. Is this the place that you also ran?

Should you be trying to run the Node backend, this is not the way.
You should type npm start from within the node project.
And the 1st time you must begin with npm install.

Very likely your problem comes from there.

Hi there,

Thanks for your response. so the npm install is already done however when I try to do npm start I faced the below issue:

and here is what I have in the index.js

const winston = require(“winston”);
const express = require(“express”);
const config = require(“config”);
const app = express();

require(“./startup/logging”)();
require(“./startup/cors”)(app);
require(“./startup/routes”)(app);
require(“./startup/db”)();
require(“./startup/config”)();
require(“./startup/validation”)();

const port = process.env.PORT || config.get(“port”);
const server = app.listen(port, () =>
winston.info(Listening on port ${port}...)
);

module.exports = server;

I am running into the same exact issue, were you able to figure it out @hmdrsf ?

Brittt, I was not be able to solve the issue and endup leave it behind. Please let me if you find any solution. Thanks