在webpack.config.js中添加如下配置:
target: 'node', node: { __dirname: false, __filename: false, }
详见:https://github.com/webpack/webpack/issues/1599