V2 Can't resolve 'fs' in webpack-dev-server/client
See original GitHub issueThere is an error when I use webpack-dev-server; webpack: 2.2.0-rc.1 webpack-dev-server: 2.2.0-rc.0 node: 6.6.0
ERROR in ./~/debug/src/node.js
Module not found: Error: Can't resolve 'net' in '/Users/gaopeng/work/ykpm/node_modules/debug/src'
@ ./~/debug/src/node.js 186:16-30
@ ./~/debug/src/index.js
@ ./~/sockjs-client/lib/main.js
@ ./~/sockjs-client/lib/entry.js
@ (webpack)-dev-server/client/socket.js
@ (webpack)-dev-server/client?http://local.youku.com:3333/
@ multi js/lib
webpackConfig
{
target: 'web',
context: '/Users/gaopeng/work/ykpm',
entry: {
'js/play/live': [
'webpack-dev-server/client?http://local.youku.com:3333/',
'webpack/hot/dev-server',
'js/play/live.js'
]
},
output: {
path: '/',
publicPath: '/',
filename: '[name].js',
pathinfo: false,
chunkFilename: '[name].js',
},
module: {
rules: [{
test: /.js?$/,
exclude: /node_modules/,
use: [
{ loader: 'babel-loader' }
]
}]
},
resolve: {
modules: [ '/Users/gaopeng/work/ykpm/src', 'node_modules' ],
extensions: [ '.js', '.json' ]
},
plugins:[new HotModuleReplacementPlugin()]
}
devServerConfig
{
contentBase: './static/',
https: false,
host: 'local.yk.com',
port: 3333,
hot: true,
inline: true,
stats: { colors: true }
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 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 >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 webpack | The AI Search Engine You Control
Another way is to let Webpack ignore fs module by adding "node": { "fs": "empty" } in the webpack configuration. Open side panel....
Read more >Resolve | webpack
For example, when calling import 'lodash' in ES2015, the resolve options can change where webpack goes to look for 'lodash' (see modules )....
Read more >[Node] Simple Next.js app, can't resolve 'fs' - Agents
NextJS v12+ does not support Webpack v4, which is where I think the problems with 'fs' and other packages were coming from. Either...
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

I could reproduce your issue. It’s caused by using
resolve.mainFieldsin your webpack config. If you remove that, it works. You can add custom fields to it, but be sure to add at least["browser", "module", "main"].here is template nodejs version v6.6.0 run
npm run testoutput error