In NodeJS I have:
const fs = require(\'fs\');
if (!fs.existsSync(\"some_path\")) {
...
}
But I get the error:
TypeEr
I had the same error that you have. Your vscode might have added a new module to your js file. Remove that module and your app should work just fine.
You can allow webpack to use the Node's require
and include fs
etc. by targeting node in the config:
module.exports = {
entry: './src/main.js',
target: 'node',
output: {
path: path.join(__dirname, 'build'),
filename: 'backend.js'
}
}
As described here: https://webpack.js.org/concepts/targets/ and https://webpack.js.org/configuration/target/
I was facing the same Error like TypeError: fs.existsSync is not a function
So, I figured out that in import there is one extra line added automatically that was creating this issue.
after removing this line from import
import { TRUE } from "node-sass";
the issue has been resolved.