1

I want to add log4js to my Vue project.

I created a logger.ts file wiht this code

import log4js from "log4js";

log4js.configure({
  appenders: { 
    app: { 
      type: "file", 
      filename: "./logs/app.log",
      compress: true,
      //pattern: '-yyyy-MM-dd',
      layout: {
        type: "pattern",
        pattern: "%d %p [%X{user}] %m%n",
      },
      daysToKeep: 14,
    } 
  },
  categories: { 
    default: { 
      appenders: ["app"], 
      level: "debug"
    } 
  },
});

export const logger = log4js.getLogger();

When I start my app I have this error on file node_modules/graceful-fs/polyfills.js :

Uncaught ReferenceError: process is not defined
    at node_modules/graceful-fs/polyfills.js (polyfills.js:3:15)
    at __require2 (chunk-ASBRWZGP.js?v=44740571:15:50)
    at node_modules/graceful-fs/graceful-fs.js (graceful-fs.js:2:17)
    at __require2 (chunk-ASBRWZGP.js?v=44740571:15:50)
    at node_modules/fs-extra/lib/fs/index.js (index.js:5:12)
    at __require2 (chunk-ASBRWZGP.js?v=44740571:15:50)
    at node_modules/fs-extra/lib/index.js (index.js:6:3)
    at __require2 (chunk-ASBRWZGP.js?v=44740571:15:50)
    at node_modules/streamroller/lib/RollingFileWriteStream.js (RollingFileWriteStream.js:2:12)
    at __require2 (chunk-ASBRWZGP.js?v=44740571:15:50)

How I can fix it?

betta7391
  • 103
  • 9
  • `process` is a variable found in Node environment. I assume your Vue 3 code is running on browser outside Node. It could be that library is not supported to be used on browsers. – captainskippah Sep 28 '22 at 14:38

0 Answers0