Module not found: Error: Can't resolve 'fs' in
The error is because of angular-cli
does not support modules in node like "fs" and "path". (Issue)
Add the following to the "package.json" file.
"browser": { "fs": false, "path": false, "os": false}
I hope this helps someone.
Thanks.
For me the solution was to add this to the webpack config:
config.node = { fs: 'empty',}
Another solution if you use NuxtJS:
// Build Configuration: https://go.nuxtjs.dev/config-buildbuild: { extend(config, {}) { config.node = { fs: 'empty' } }},
If you use NextJS (not tested, please confirm that it works in comments):
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => { config.node = { fs: 'empty' } return config},
In other cases, please refer to Anjana Silva post. An edit of your package.json file can do the job!
For Webpack > 5
update webpack.config.js
module.exports = { ... resolve: { fallback: { "fs": false }, }}