Getting "Module not found: Can't resolve 'fs' " Error
See original GitHub issueHello, 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](https://user-images.githubusercontent.com/45687516/158008964-0634f0bb-72f7-4eaa-a710-58101d21d30b.png)
Issue Analytics
- State:
- Created 2 years ago
- Comments:8
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Try asking on StackOverflow!
https://stackoverflow.com/help/how-to-ask