question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Getting "Module not found: Can't resolve 'fs' " Error

See original GitHub issue

Hello, I am using NextJs for development, when I try to log my errors using this ( winston ), I got “Module not found: Can’t resolve ‘fs’” error. I don’t know what I did wrong here, Kindly someone give me a solution. Thanks in advance.

I post my logger config here,

`import { createLogger, format, transports } from 'winston';
import 'winston-daily-rotate-file';

const getLogger = (fileName = 'application') => {
    const fileLogTransport = new transports.DailyRotateFile({
        filename: `logs/${fileName}-%DATE%.log`,
        datePattern: 'YYYY-MM-DD',
        zippedArchive: true,
        maxSize: '20m',
        maxFiles: '30d',
    });

    const consoleTransport = new transports.Console({
        level: process.env.LOG_LEVEL,
        handleExceptions: false,
        json: false,
        colorize: true,
        format: format.printf((i) => `${i.message}`),
    });

    const logger = createLogger({
        level: 'error',
        format: format.combine(
            format.timestamp({
                format: 'YYYY-MM-DD',
            }),
            format.errors({ stack: true }),
            format.splat(),
            format.printf(
                ({ level, message, label = process.env.NODE_ENV, timestamp }) =>
                    `${timestamp} [${label}] ${level}: ${message}`
            )
        ),
        // defaultMeta: { service: 'my-app' },
        transports: [consoleTransport],
    });
    //
    if (process.env.NODE_ENV === 'development') {
        logger.add(fileLogTransport);
    }

    return logger;

};

export default getLogger();`
FS not found

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
wbtcommented, Jul 15, 2022

Try asking on StackOverflow!

0reactions
wbtcommented, Oct 19, 2022

You’d better add a StackOverflow link or add some tips here.

https://stackoverflow.com/help/how-to-ask

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Error: Can't resolve 'fs' in - Stack Overflow
I found a possible solution, that you have to put some configuration in one of the node_modules. But I think that is not...
Read more >
Can't resolve 'fs' error in Next.js and WebPack - Nsikak Imoh
The Module not found: Can't resolve 'fs' in Next.js error occurs when you import a Node.js module that is not available in the...
Read more >
How To Solve Module Not Found Can't Resolve 'fs' in Next.js
The Module not found: Can't resolve 'fs' error and similar issues most likely occur when you try to import a module that is...
Read more >
module not found error can't resolve 'fs' in react js - You.com
The "Module not found: Can't resolve 'fs'" error in React is caused by a missing or incorrect dependency. To solve this problem, you...
Read more >
Module not found: Error: Can't resolve 'fs' - Laracasts
hi, when run gulp get error not found fs module // depend fs let dir = require('node-dir'); //or let fs = require('fs'); dir.path(__dirname,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found