Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
issam-seghir opened this issue Feb 5, 2024 · 1 comment
Open

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

issam-seghir opened this issue Feb 5, 2024 · 1 comment

Comments

@issam-seghir
Copy link

issam-seghir commented Feb 5, 2024

  • server.js
// 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",
		},
	})
);
  • package.json
	"scripts": {
		"dev": "node --watch --env-file=.env.development.local  server.js | pino-pretty",
		"prod": "node --watch --env-file=.env  server.js",
	},
...\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
Copy link
Member

mcollina commented Feb 7, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants