SOLVED: Webpack warning about not found "fs" module
See original GitHub issueI get the following warning when building my webapp with webpack:
[1] WARNING in ../node_modules/tfjs-image-recognition-base/build/es6/env/initialize.js
[1] Module not found: Error: Can't resolve 'fs' in '/Users/username/project/node_modules/tfjs-image-recognition-base/build/es6/env'
[1] @ ../node_modules/tfjs-image-recognition-base/build/es6/env/initialize.js
[1] @ ../node_modules/tfjs-image-recognition-base/build/es6/env/index.js
[1] @ ../node_modules/tfjs-image-recognition-base/build/es6/index.js
[1] @ ../node_modules/face-api.js/build/es6/index.js
[1] @ ./src/index.tsx
I had to add the following to my webpack config to suppress the warning:
node: {
fs: "empty"
}
It’s weird because the target in my webpack config is set to web
.
Am I doing something wrong? If not, this issue may help other people with the same warning.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Module not found: Error: Can't resolve 'fs' in - Stack Overflow
For me the solution was to add this to the webpack config: config.node = { fs: 'empty', }. Another solution if you use...
Read more >Module not found: Can't resolve 'fs' error [Solved] | bobbyhadz
The error "Module not found: Error: Can't resolve 'fs'" occurs because there has been a breaking change in Webpack version 5. To solve...
Read more >module not found error can't resolve 'fs' react js - You.com
Here is a full solution to end the 'fs' error once and for all. In theory, you can do the following: Eject your...
Read more >Next.js + Webpack - Fix for ModuleNotFoundError: Module not ...
To fix the error with Webpack 4, update your Next.js config file ( /next.config.js ) with the following, it tells webpack to set...
Read more >Module Methods - webpack
This section covers all methods available in code compiled with webpack. ... No CommonJS allowed, for example, you can't use require , module.exports...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For webpack 5 you need:
This really should be fixed in this lib though. Having to do this in my webpack config is clunky.
Thanks for reporting your solution!
It’s because webpack sees the require(‘fs’) in the code, but although it won’t be required in a browser environment. face-api.js is not only a library for the browser anymore, if you are running in a nodejs environment fs will be required and used for reading model files from disk.