0

I'm returning to an old fluxible project I started a while back and when I use npm run dev it seems to be starting twice and is throwing an error. It used to work - what is the configuration that's causing this error? Is the standard fluxible configuration supposed to be running two web servers one on port 3000 and one on 3001?

> node webpack-dev-server.js & PORT=3001 nodemon start.js -e js,jsx

[nodemon] 1.8.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node start.js`
Webpack Dev Server listening on port 3000
[nodemon] 1.8.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node start.js`
using redis session
Application listening on port 3001
events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE :::3001

I noticed that in the webpack-dev-server.js it is also calling start.js as well.

var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require('./webpack.config');
var shell = require('shelljs');

new WebpackDevServer(webpack(config), {
    publicPath: config.output.publicPath,
    hot: true,
    historyApiFallback: true,
    //quiet: true,
    proxy: {
        '*': { target: 'http://localhost:3001' }
    }
}).listen(3000, function () {
    shell.env.PORT = shell.env.PORT || 3001;
    shell.exec('"./node_modules/.bin/nodemon" start.js -e js,jsx', function () {});
    console.log('Webpack Dev Server listening on port 3000');
});

maybe that shell.exec call to start.js is redundant?

MonkeyBonkey
  • 46,433
  • 78
  • 254
  • 460

1 Answers1

0

I think your intuition is correct. Try running this command:

node webpack-dev-server.js

Whats happening is, the node program (webpack-dev-server.js) starts a webpack-dev-server on port 3000, and then starts a nodemon service on port 3001. The command you are running in the terminal is using a ampersand, so it's also starting a third server in parallel. This server is also running on port 3001.

I suspect the error being raised is caused by the port already being used by the parallel process.

cgatian
  • 22,047
  • 9
  • 56
  • 76