question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebPack - Issue : Error: Can't resolve 'fs'

See original GitHub issue

Thank you for submitting an issue to jsPDF. Please read carefully.

Are you using the latest version of jsPDF?

The issue occurs after upgrading from 1.3.5 to 1.4.0 (npm version). My project uses Webpack to build a bundle.

Have you tried using jspdf.debug.js?

I did. the error occurs on line 5387:14-27 (var fs = require('fs');)

  		var nodeJSMethod = function nodeJSMethod(path, sync, callback) {
  			sync = sync || true;
  			var fs = require('fs');
  			if (sync === true) {
  				var data = fs.readFileSync(path).toString();
  				return data;
  			} else {
  				fs.readFile('image.jpg', function (err, data) {
  					callback(data);
  				});
  			}
  		};

Steps to reproduce

It happens when I use webpack to build my project

Ideally a link too. Try fork this http://jsbin.com/rilace/edit?html,js,output

What I saw

ERROR in ./node_modules/jspdf/dist/jspdf.debug.js
Module not found: Error: Can't resolve 'fs' in '.\node_modules\jspdf\dist'
 @ ./node_modules/jspdf/dist/jspdf.debug.js 5387:14-27

What I expected

Expected webpack to complete without error as it did in v1.3.5

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:17
  • Comments:25 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
lordgregcommented, May 25, 2018

Same issue. We cannot update our projects to Angular6 because of this issue. Would appreciate any workaround.

5reactions
inthegaragecommented, May 25, 2018

@arasabbasi At the moment I can’t get angular to work with this version, and I don’t want to eject my project into a webpack one. It’s possible it doesn’t work anymore. If anyone has a solution, then please post here.

Read more comments on GitHub >

github_iconTop 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 >
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 >
can't resolve fs in node_modules - You.com | The AI Search ...
I think the problem is related to webpack, I had the same problem on a next js project and here's ... Module not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found