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,
}
}
}
}