Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try other ports when port 9000 is already used #3204

Open
3 tasks done
xavierlint opened this issue Apr 1, 2023 · 3 comments · May be fixed by #3534
Open
3 tasks done

Try other ports when port 9000 is already used #3204

xavierlint opened this issue Apr 1, 2023 · 3 comments · May be fixed by #3534
Labels
enhancement plugin/webpack Issues or pull requests related to first-party webpack plugins/templates

Comments

@xavierlint
Copy link

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project uses.
  • I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Problem description

When running npm start in a just-created project, I saw:

image

Proposed solution

Try other ports when port 9000 is already used.

Alternatives considered

  • Not trying out other ports: status quo, 0 development required, but 0 support for other ports different than 9000.

Additional information

Please.

@maccman
Copy link

maccman commented Apr 12, 2023

Or allow us to specify a custom port.

@BlackHole1
Copy link
Member

BlackHole1 commented Apr 13, 2023

It looks like you can modify the default port by configuration.🤔 Can you try it?

* The TCP port for web-multi-logger. Defaults to 9000.
*/
loggerPort?: number;

https://js.electronforge.io/interfaces/_electron_forge_plugin_webpack.WebpackPluginConfig.html#loggerPort

module.exports = {
  //...
  plugins: [
    {
      name: '@electron-forge/plugin-webpack',
      config: {
+       loggerPort: 9001,
        mainConfig: './webpack.main.config.js',
        renderer: {
          config: './webpack.renderer.config.js',
          entryPoints: [{
            name: 'main_window',
            html: './src/renderer/index.html',
            js: './src/renderer/index.js',
            preload: {
              js: './src/preload.js'
            }
          }],
        }
      }
    }
  ]
  //...
}

@erickzhao erickzhao added the plugin/webpack Issues or pull requests related to first-party webpack plugins/templates label Apr 18, 2023
@xavierlint
Copy link
Author

Thanks! Indeed this was useful, for sure there was a way to configure it, but the sole fact of it being non-trivial made me create this issue. I suggest one of the following alternatives:

  • Add the port-probing mechanism, check for availability of a port from 9000 to 9999, for example, and fail if none is available
  • Add the line with the loggerPort: 9000, to the config generated by the npm init electron-app@latest my-app or yarn create electron-app my-app commands (or any other command that generates a project from a template). It would be redundant, for sure, since 9000 is a default value, but it would also be very convenient since changing the port would be trivial. I assume everyone will try first CTRL + F, and then 9000, and this time they'll find something, and be able to change it to make it work.

Thanks again!

@DevanceJ DevanceJ linked a pull request Mar 14, 2024 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement plugin/webpack Issues or pull requests related to first-party webpack plugins/templates
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants