Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.9k views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...