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 3 can't resolve 'fs' and 'net'

See original GitHub issue

I updated to Webpack 3, if I add the plugin in resolve’s plugins list I have this error in console.

Module not found: Error: Can't resolve 'fs' in '/MY-PROJ-DIR/node_modules/debug/src'
 @ ./node_modules/debug/src/node.js 184:15-28
 @ ./node_modules/debug/src/index.js
 @ ./node_modules/sockjs-client/lib/main.js
 @ ./node_modules/sockjs-client/lib/entry.js
 @ (webpack)-dev-server/client/socket.js
 @ (webpack)-dev-server/client?http://localhost:8080
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server react-hot-loader/patch webpack/hot/only-dev-server ./src/index.js

ERROR in ./node_modules/debug/src/node.js
Module not found: Error: Can't resolve 'net' in '/MY-PROJ-DIR/node_modules/debug/src'
 @ ./node_modules/debug/src/node.js 191:16-30
 @ ./node_modules/debug/src/index.js
 @ ./node_modules/sockjs-client/lib/main.js
 @ ./node_modules/sockjs-client/lib/entry.js
 @ (webpack)-dev-server/client/socket.js
 @ (webpack)-dev-server/client?http://localhost:8080
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server react-hot-loader/patch webpack/hot/only-dev-server ./src/index.js```

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
shaketbabycommented, Jun 22, 2017

Looks like sockjs-client will require module debug if it not PROD env which tries to detect and ends up importing the file for Node.js instead of browser. Can you try to specify honorPackage option to look for browser first?

new DirectoryNamedWebpackPlugin({
  honorPackage: ["browser", "main"],
  // any other options needed
})

Please let me know if this works.

0reactions
tomasfranciscocommented, Jul 21, 2017

Hi @shaketbaby, I was having the same problem here. The honorPackage has resolved the issue.

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 >
webpack module not found: error: can't resolve 'fs' - You.com
For a frontend/web project, add the socket.io client libary to your app bundle. There is no need to include any node dependencies (...
Read more >
Error: Can't resolve 'fs' in (Webpack 5.72.0) - CSDN博客
报错:ERROR in ./node_modules/handlebars/lib/index.js 17:11-24Module not found: Error: Can't resolve 'fs' in ...
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