Serve for the client uses a hardcoded port
See original GitHub issueThe client port is hardcoded which makes it not possible to provide an alternative port via the package.json.
Steps to reproduce the behavior:
$ mevn init test
$ cd test
# set a port in package.json for the dev script
$ sed -i 's/dev": "nuxt/dev": "nuxt --port 8080/' client/package.json
$ mevn serve
__ __ _______ ___ _ ____ _ ___
| \/ | ____\ \ / / \ | | / ___| | |_ _|
| |\/| | _| \ \ / /| \| | | | | | | |
| | | | |___ \ V / | |\ | | |___| |___ | |
|_| |_|_____| \_/ |_| \_| \____|_____|___|
Light speed setup for MEVN stack based apps.
? Choose from below client
> nuxt@1.0.0 dev
> nuxt --port 8080 "--port" "3000" "--open"
WARN mode option is deprecated. You can safely remove it from nuxt.config 06:05:57
FATAL options.port should be >= 0 and < 65536. Received NaN.
Expected behavior:
to be able to specify port and host in the package.json for scripts
$ cd client/
$ npm run dev
> nuxt@1.0.0 dev
> nuxt -H 0.0.0.0 --port 8080
...
โน Waiting for file changes 06:21:30
โน Memory usage: 200 MB (RSS: 286 MB) 06:21:30
โน Listening on: http://172.16.16.16:8080/
Modified /usr/lib/node_modules/mevn-cli/lib/commands/serve/launch.js
From:
61 _execa["default"].command("npm run ".concat(cmd, " -- --port ").concat(port, " --open"), {
To:
61 _execa["default"].command("npm run ".concat(cmd, " -- --open"), {
Now it works as expected:
$ mevn serve
__ __ _______ ___ _ ____ _ ___
| \/ | ____\ \ / / \ | | / ___| | |_ _|
| |\/| | _| \ \ / /| \| | | | | | | |
| | | | |___ \ V / | |\ | | |___| |___ | |
|_| |_|_____| \_/ |_| \_| \____|_____|___|
Light speed setup for MEVN stack based apps.
? Choose from below client
> nuxt@1.0.0 dev
> nuxt -H 0.0.0.0 --port 8080 "--open"
WARN mode option is deprecated. You can safely remove it from nuxt.config
โญโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ โ
โ Nuxt @ v2.15.4 โ
โ โ
โ โธ Environment: development โ
โ โธ Rendering: server-side โ
โ โธ Target: server โ
โ โ
โ Listening: http://172.16.16.16:8080/ โ
โ โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ
โน Preparing project for development 06:12:06
โน Initial build may take a while 06:12:06
โน Discovered Components: .nuxt/components/readme.md 06:12:06
โ Builder initialized 06:12:06
โ Nuxt files generated 06:12:06
โ Client
Compiled successfully in 2.63s
โ Server
Compiled successfully in 1.58s
โน Waiting for file changes 06:12:09
โน Memory usage: 205 MB (RSS: 295 MB) 06:12:09
โน Listening on: http://172.16.16.16:8080/
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Why port 80 is used for server applications? - Stack Overflow
Server port number has to be hard coded in server and client application? Yes, that is one way to do it. Server port...
Read more >Why not hard-code the port number for an application that will ...
Suppose I am creating an Express app that will be dockerized. What's wrong with making it listen to a hard-coded port, e.g. 8080:...
Read more >What hard coded ports are used by CONTROL-M products, for ...
- Database ports. Sybase: Defaults are 7102 and 7103. One port is used by the dataserver processes and one by the backupserver processes.ย ......
Read more >Explicitly assigning port number to client in Socket
So, it is highly probable that the port number provided to the client by the operating system may have been blocked by the...
Read more >force program hardcoded to listen on a port to use another port?
You have a client program on machine A that makes HTTP requests to machine B on port 80. And you have a server...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Iโd suggest making the following changes in src/commands/serve/launch.js
might want to do the same for the server.
itโs a bit easier to override since I could edit server.js or the port env var, but probably better to allow it to be set in package.json.
I was able to override it to port 8008 but the server startup message still says its going to uae 9000.