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.

Winston 3.2 Uncaught TypeError: fs.existsSync is not a function

See original GitHub issue
  • _winston version 3.2
  • _Operating System? macOS
  • Node JS, React framework

What is the problem?

winstonLogger.Log() fails with the exception:

Uncaught TypeError: fs.existsSync is not a function
at File._createLogDirIfNotExist (file.js:804)
at new File (file.js:132)
at Object. (mylogger.js:16)
at webpack_require (bootstrap 284d16fcfe1dcfa44176:676)
at fn (bootstrap 284d16fcfe1dcfa44176:87)
at Object. (mymodule.js:5)
at webpack_require (bootstrap 284d16fcfe1dcfa44176:676)
at fn (bootstrap 284d16fcfe1dcfa44176:87)
at Object. (app.js:21)
at webpack_require (bootstrap 284d16fcfe1dcfa44176:676)

What do you expect to happen instead?

I expect the .log() function to log to a file transport

Other information

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:8
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
dwalintukancommented, Apr 16, 2019

I am experiencing similar logs with Webpack 4. It breaks my React app entirely.

file.js:804 Uncaught TypeError: fs.existsSync is not a function
    at File._createLogDirIfNotExist (file.js:804)
    at new File (file.js:132)
    at eval (logger.js:18)
    at Module../src/utils/logger.js (bundle.js:72383)
    at __webpack_require__ (bundle.js:20)
    at eval (index.js:11)
    at Module../src/localization/index.js (bundle.js:72133)
    at __webpack_require__ (bundle.js:20)
    at eval (index.js:14)
    at Module../src/index.js (bundle.js:72110)
4reactions
oshiniGcommented, Jun 7, 2019

Is there any solution for this TypeError: fs.existsSync is not a function error? what is the default file location ?

import winston from "winston";

const logger = winston.createLogger({
  level: 'info',
  format: winston.format.json(),
  defaultMeta: { service: 'user-service' },
  transports: [
    new winston.transports.File({ filename: 'error.log', level: 'error' }),
    new winston.transports.File({ filename: 'combined.log' })
  ]
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: fs.existsSync is not a function - Stack Overflow
fs is a nodejs library so you can't use it on browser side. Use winston-transport-browserconsole instead.
Read more >
How To Resolve Fs.Existssync Is Not A Function - ADocLib
existsSync method is used to synchronously check if a file already exists in the given path or not. It returns a fs.existsSync method....
Read more >
TypeError: fs.existsSync is not a function - DEV Community ‍ ‍
While using Sass in a react project and using useRef hook, one might come across this error: React and Sass error.
Read more >
How to solve: TypeError: fs.existsSync is not a function - Reddit
TypeError : fs.existsSync is not a functionhasBinarynode_modules/node-sass/lib/extensions.js:405 402 | */ 403 | 404 | function ...
Read more >
Please am getting an error on my react electron app "TypeError
Please am getting an error on my react electron app "TypeError: fs.existsSync is not a function" below are my codes.
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