If you use Webpack version 5 or later you may encounter the error message
Module not found: Can’t resolve ‘fs’
The cause is, that Webpack 5 has a breaking change, and the “fs” module is most likely not included anymore in the client-side code.
To eliminate the issue, add the “browser” element to the package.js file under dependencies:
{
"dependencies": {
...
},
"browser": {
"fs": false,
"os": false,
"path": false
}
}
If the error persists, add the “fs”, “os” and “path” elements to the fallback element in the webpack.config.js file:
module.exports = function (webpackEnv) {
...
return {
...
resolve: {
...
fallback: {
"fs": false,
"os": false,
"path": false,
}
}
}
}
If I do this, I get this error
“`fs.readFileSync is not a function“`
or
“`fs.readFile is not a function“`
Any idea why and how to fix it?
STILL NO IDEA , STRUCK IN SAME LOOP :( . IF YOU HAVE ANY SOLUTION TO DO THIS PLEASE LET ME KNOW