Can't resolve 'fs' with WebPack
See original GitHub issueWhen I try to load ejs
within a WebPack project with import ejs from 'ejs'
I get:
Module not found: Error: Can't resolve 'fs' in 'node_modules/ejs/lib'
Is there something I need to do to make it work client-side or what? Thanks.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Module not found: Error: Can't resolve 'fs' in - Stack Overflow
I found a possible solution, that you have to put some configuration in one of the node_modules. But I think that is not...
Read more >Can't resolve 'fs' when bundle with webpack #447 - GitHub
I got this error when using the "fetch" library from npm. At first I got the same error but with other packages (...
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 >can't resolve fs in node_modules - You.com | The AI Search ...
Your quick fix is to take react scripts down to v4 until a fix for v5 is in place unless you are comfortable...
Read more >Module not found | Can't resolve 'fs' in Next js application
Join this channel to get access to perks:https://www.youtube.com/channel/UCoSpmr2KNOxjwE_B9ynUmig/joinMy GearCamera ...
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 Free
Top 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
@mde Thanks to your comment I was able to get it working, actually in two ways.
First way: drop the built-and-minified JS file into my project and
require('ejs')
just before I want to use it. Then I can doejs.render(string, data)
etc. The only downside is I couldn’t figure out how to load up separate template files; but instead I can put templates in my html within<script type="x-template"></script>
tags.Second way: configure webpack with ejs-compiled-loader as a loader for
*.ejs
files, and then simplyconst template = require('some_template.ejs')
where I want to use it. I don’t need a separaterequire('ejs')
.Thanks for the help!
The built-and-minified JS file in every release is now compiled with the Browserify
--standalone
flag, which should provide AMD support and ought to work with WebPack. If you’re using it client-side, that might be easier than trying to finagle the build yourself.