Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve fs.existsSync is not a function

In NodeJS I have:

const fs = require('fs');
if (!fs.existsSync("some_path")) {
...
}

But I get the error:

TypeError: fs.existsSync is not a function

After doing some searching, I read that Webpack brings its own require which clobbers node.js's require, so when you require a node.js core module that webpack can't resolve to one of your files or dependencies, it throws.

(My stack trace includes __webpack_require__)

But how can I fix it?

like image 901
Gambit2007 Avatar asked Dec 18 '18 21:12

Gambit2007


1 Answers

I was facing the same Error like TypeError: fs.existsSync is not a function

enter image description here

So, I figured out that one extra line was added automatically which was creating this issue in import.

enter image description here

after removing this line from import

import { TRUE } from "node-sass";

the issue has been resolved.

like image 105
Krunal Rajkotiya Avatar answered Oct 02 '22 14:10

Krunal Rajkotiya