Webpack Express Cannot Resolve Module 'fs', Request Dependency is Expression
I solved this problem by two steps:
Delete
node_modules
directoryAdd
target:'node'
into webpack config file
Then run npm install
. It worked for me fine.
Just posting an answer, since not everyone reads comments on SO. @Aurora0001 nailed it. Webpack's config needs to have this set:
"target": "node"
I am on a stack Angular 2 - Electron - Webpack and I needed to use fs into my service, I finally found how to do :
1) inside your webpack.common.js, specify target:'electron-renderer'
2) inside your service or component : import * as fs from 'fs';
and use fs as would do for a node project.
Hope it help !
I added node: { fs: 'empty' }
without luck,
then I added --config to start command:
webpack-dev-sever webpack.config.dev.js
Use --config flag to use the custom file.
webpack-dev-sever --config webpack.config.dev.js