JaniAnttonen / winston-loki

Grafana Loki transport for the nodejs logging library Winston.
MIT License
144 stars 54 forks source link

Module parse failed error on Next.js 14 #156

Open abdllhcay opened 6 months ago

abdllhcay commented 6 months ago

I got this error on my Next.js 14.0.4 app when I call logger like logger.info("Hello World");

./node_modules/@napi-rs/snappy-win32-x64-msvc/snappy.win32-x64-msvc.node
Module parse failed: Unexpected character '�' (1:2)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)

Here is my logger.ts file.

import winston from "winston";
import LokiTransport from "winston-loki";

const { combine, timestamp, json } = winston.format;

const logger = winston.createLogger({
  level: "info",
  format: combine(timestamp(), json()),
  transports: [
    new winston.transports.Console({}),
    new LokiTransport({
      host: "http://127.0.0.1:3100",
      labels: {
        app: "my-app",
      },
    }),
  ],
});

export default logger;
wuyiqunLu commented 5 months ago

Experienced same issue on prod build, did you figure out the solution? @abdllhcay

abdllhcay commented 5 months ago

Experienced same issue on prod build, did you figure out the solution? @abdllhcay

No, I couldn't find a solution. So I switched to using pino-loki.