Module not found: Error: Can't resolve 'fs'

[已解决]ERROR in ./node_modules/electron/index.js,Module not found: Error: Can't resolve 'fs' in。

ERROR in ./node_modules/electron/index.js,Module not found: Error: Can't resolve 'fs' in。

Module not found: Error: Can't resolve 'fs' in '.....\node_modules\electron'。

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

resovled

在webpack中加入target项:

webpack.config.js

module.exports = {
  ....
  target: "web" | "webworker" | "node" | "async-node" | "node-webkit" | "electron-main" | "electron-renderer" |"
  ....
};

Example:

module.exports = {  
  target: "electron-main"
};