easy-team / egg-webpack

Egg Webpack Dev Server Plugin, Support Memory File and Hot-Reload
https://easyjs.cn
MIT License
68 stars 16 forks source link

无法启动多个webpack,报错 ERROR 10316 nodejs.unhandledExceptionError: listen EADDRINUSE #24

Closed shanliang closed 3 years ago

shanliang commented 4 years ago

我的config.default.js config.webpack = { port: 8000, webpackConfigList: [require('../edesign/scripts/webpack.dev1.config.js'),require('../edesign/scripts/webpack.dev2.config.js') ], } 错误 ERROR 10316 nodejs.unhandledExceptionError: listen EADDRINUSE

初步排查 当我如上配置两个 程序还是 进入了utils/server.js 而不是 utils/mult-process-server.js getPort(target = 'web', offset = 0) { const EASY_ENV_DEV_PORT = EASY_ENV_DEV_PORT_${this.pkgInfo.name}; const port = this.config.port || Number(process.env[EASY_ENV_DEV_PORT]) || 9000; if (target === 'web') { return port; } return port + offset; } 而我的程序运行target 为web 默认返回了同个端口 所以端口冲突了

hubcarl commented 4 years ago

@shanliang 多个 target:web 支持了一下,需要开启 egg-webpack 的 offsetPort 配置,然后重新安装依赖。

// ${root}/config/config.local.js
 exports.webpack = {
    offsetPort: true,
    webpackConfigList: [....]
  };

https://github.com/easy-team/webpack-tool/commit/89c1053b8e19292ca38081fdf221b380a761069d