Skip to content

Serve for the client uses a hardcoded port #220

Open
@koaps

Description

@koaps

The 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

> [email protected] 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

> [email protected] 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

> [email protected] 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/

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions