pinojs / pino

🌲 super fast, all natural json logger
http://getpino.io
MIT License
14.26k stars 876 forks source link

Cannot read properties of undefined (reading 'log') #1896

Open issam-seghir opened 9 months ago

issam-seghir commented 9 months ago
// add alias
require("module-alias/register");

const express = require("express");
const pino = require("pino-http")();
....

const PORT = process.env.PORT || 3000;

const app = express();

// pino logger
app.use(
    pino({
        transport: {
            target: "pino-pretty",
        },
    })
);
...\server\node_modules\pino-http\logger.js:153     
if (!res.log) {             
 ^  TypeError: Cannot read properties of undefined (reading 'log')     at loggingMiddleware 
 (E:\Documents\Vs Code\My app\server\node_modules\pino-http\logger.js:153:14)     
 at result (E:\Documents\Vs Code\My app\server\node_modules\pino-http\logger.js:89:12)     at Object.<anonymous>
  (E:\Documents\Vs Code\My app\server\server.js:44:2)     at Module._compile (node:internal/modules/cjs/loader:1376:14)     at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)     at Module.load (node:internal/modules/cjs/loader:1207:32)     at Module._load (node:internal/modules/cjs/loader:1023:12)    
   at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)     at node:internal/main/run_main_module:28:49
     Node.js v20.10.0
mcollina commented 8 months ago

Thanks for reporting!

Can you provide steps to reproduce? We often need a reproducible example, e.g. some code that allows someone else to recreate your problem by just copying and pasting it. If it involves more than a couple of different file, create a new repository on GitHub and add a link to that.