Module not found: Error: Cannot resolve module 'fs'
See original GitHub issueI am using the babel generator boilerplate for a library I am building. I added this library and imported it into my project. Now when I run gulp build I get the following error. Any assistance would be highly appreciated.
stream.js:74
throw er; // Unhandled stream error in pipe.
^
Error: ./~/json-schema-ref-parser/lib/resolvers/file.js
Module not found: Error: Cannot resolve module 'fs' in /home/raphael/work/projects/packages/json-schema-form-generator/node_modules/json-schema-ref-parser/lib/resolvers
resolve module fs in /home/raphael/work/projects/packages/json-schema-form-generator/node_modules/json-schema-ref-parser/lib/resolvers
looking for modules in /home/raphael/work/projects/packages/json-schema-form-generator/node_modules
/home/raphael/work/projects/packages/json-schema-form-generator/node_modules/fs doesn't exist (module as directory)
resolve 'file' fs in /home/raphael/work/projects/packages/json-schema-form-generator/node_modules
resolve file
/home/raphael/work/projects/packages/json-schema-form-generator/node_modules/fs doesn't exist
/home/raphael/work/projects/packages/json-schema-form-generator/node_modules/fs.webpack.js doesn't exist
/home/raphael/work/projects/packages/json-schema-form-generator/node_modules/fs.web.js doesn't exist
/home/raphael/work/projects/packages/json-schema-form-generator/node_modules/fs.js doesn't exist
/home/raphael/work/projects/packages/json-schema-form-generator/node_modules/fs.json doesn't exist
[/home/raphael/work/projects/packages/json-schema-form-generator/node_modules/fs]
[/home/raphael/work/projects/packages/json-schema-form-generator/node_modules/fs]
[/home/raphael/work/projects/packages/json-schema-form-generator/node_modules/fs.webpack.js]
[/home/raphael/work/projects/packages/json-schema-form-generator/node_modules/fs.web.js]
[/home/raphael/work/projects/packages/json-schema-form-generator/node_modules/fs.js]
[/home/raphael/work/projects/packages/json-schema-form-generator/node_modules/fs.json]
@ ./~/json-schema-ref-parser/lib/resolvers/file.js 2:14-27
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Module not found: Error: Cannot resolve module 'fs'
From what I understand, the main issue seems to be that you can't call server-side (Node) methods in browser-interpreted client-side (front end) ...
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 >How To Solve Module Not Found Can't Resolve 'fs' in Next.js
The Module not found: Can't resolve 'fs' error and similar issues most likely occur when you try to import a module that is...
Read more >Can't resolve 'fs' error in Next.js and WebPack - Nsikak Imoh
The Module not found: Can't resolve 'fs' in Next.js error occurs when you import a Node.js module that is not available in the...
Read more >Module not found: Error: Can't resolve 'fs' · Issue #2279 - GitHub
Go to webpack.base.babel.js inside /internals/webpack ... And add somewhere close to the bottom... mines directly above devtool: options ...
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 Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I had the same problem. Solved it by adding the alias in webpack so it knows where to find the correct asset.
resolve : { alias: { 'json-schema-parser': __dirname + '/node_modules/json-schema-ref-parser/dist/ref-parser.js' } }
and you use it as you would normally but use the alias key
var parser = require('json-schema-parser')
Thank you!