Can't resolve 'fs' in .../...node_modules\pdfkit\js' - webpack loader issue
See original GitHub issueMy webpack.config.js looks like this:
module.exports = {
// devtool: 'source-map',
entry: './src/app.js',
output: {
path: path.resolve (__dirname, "dist"),
filename: "bundle.js"
},
module : {
rules : [
{ test: /\.js$/, loader: 'babel-loader' },
{
test : /\.html$/,
use : [ 'html-loader' ]
}
]
},
plugins:
[ new HtmlWebpackPlugin ({
template : `src/app.html`
})
]
};
In my app.js
i have just this line: - nothing else.
const PDFDocument = require ('pdfkit');
Which gives me the following errors:
ERROR in ./~/pdfkit/js/document.js
Module not found: Error: Can't resolve 'fs' in 'E:\0000 Path..\node_modules\pdfkit\js'
@ ./~/pdfkit/js/document.js 26:7-20
@ ./src/app.js
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/app.js
ERROR in ./~/pdfkit/js/image.js
Module not found: Error: Can't resolve 'fs' in 'E:\0000 Path...\node_modules\pdfkit\js'
@ ./~/pdfkit/js/image.js 11:7-20
@ ./~/pdfkit/js/mixins/images.js
@ ./~/pdfkit/js/document.js
@ ./src/app.js
@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/app.js
I can’t get this library working with webpack in any way. Please can you give me an example that uses webpack instead of broweseify?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:11
- Comments:16 (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 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 >pdfkit - Bountysource
Can't resolve 'fs' in .../...node_modules \pdfkit\js' - webpack loader issue ... My webpack.config.js looks like this: module.exports = { // ...
Read more >Module not found: Error: Can't resolve 'fs' - Laracasts
[01:02:59] Starting 'webpack'... { [Error: ./resources/assets/js/router.js Module not found: Error: Can't resolve 'fs' in ...
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 >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
Does anyone know whether PDFKit is compatible with WebPack version 4? The previous solutions do not work anymore … I’m getting
Can't resolve 'fs'
for pdfkit/js/document.js, pdfkit/js/image.js, pdfkit/js/font/afm.js, png-js/png-node.js.
I have no clue what has changed from WebPack 3 to WebPack 4 … If anyone has got this working with WebPack 4.0, I’d very much appreciate it.
I ran into the same problem and adding these 2 loaders into
webpack
’s config solved the problem. Basically they makewebpack
run allpdfkit
-related packages throughbrowserify
with thebrfs
transform (by invoking thetransform-loader
) and also inline the./data.json
file insideunicode-properties
(one ofpdfkit
’s dependencies) (invoking thejson-loader
). Note that you also need to install thebrfs
module.I didn’t have to set
{node: {fs: 'empty'}}
.