ionic-team / ionic-team/ionic-cli

Don't use `--` when the `npmClient` is `pnpm`

Abierto
#5,020 1 comentario 1 reacción 0 asignados Ver en GitHub
triage
Lenguaje dominante
TypeScript
Estrellas
2k
Forks
682
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

**Description:**

When running `ionic capacitor run android --livereload --external`, I get an endless loop of `[INFO] Waiting for connectivity with pnpm...`

```log
> pnpm run ionic:serve -- --host=0.0.0.0 --port=8100
[pnpm] > theia-mobile@0.1.1 ionic:serve /home/nato/Code/github.com/Omerlo-Technologies/theia-mobile
[pnpm] > vite dev "--" "--host=0.0.0.0" "--port=8100"
[pnpm] VITE v4.3.9 ready in 474 ms
[pnpm] ➜ Local: http://localhost:5173/
[pnpm] ➜ Network: use --host to expose
[pnpm] ➜ press h to show help
[INFO] Waiting for connectivity with pnpm...
[INFO] Waiting for connectivity with pnpm...
[INFO] Waiting for connectivity with pnpm...
```

The issue is that `pnpm run ionic:serve -- --host=0.0.0.0 --port=8100` doesn't work as expected because of that `--` in the middle. `--` is useful when you want `npm` to pass additional command-line arguments to scripts, but `pnpm` isn't limited by this restriction and it passes the whole thing. When `vite` receives that, it ignores everything after it.

This can be tested:

```sh
❯ vite dev --host=0.0.0.0 --port=8100

VITE v4.3.9 ready in 527 ms

➜ Local: http://localhost:8100/
➜ Network: http://192.168.1.213:8100/
➜ Network: http://192.168.1.214:8100/
➜ press h to show help

❯ vite dev -- --host=0.0.0.0 --port=8100

VITE v4.3.9 ready in 519 ms

➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h to show help
```

**Steps to Reproduce:**

1. Have a Vite app (ex: SvelteKit)
2. Setup Capacitor and Ionic
```json
{
"name": "Hello World",
"integrations": {
"capacitor": {}
},
"type": "custom",
"npmClient": "pnpm"
}
```
3. Set these scripts in `package.json`
```json
"dev:android": "ionic capacitor run android --livereload --external",
"ionic:serve": "vite dev",
```
4. Run `pnpm dev:android`

**Output:**

**My `ionic info`:**

```yaml
Ionic:

Ionic CLI : 7.1.1 (/home/nato/.local/share/pnpm/global/5/.pnpm/@ionic+cli@7.1.1/node_modules/@ionic/cli)

Capacitor:

Capacitor CLI : 5.0.5
@capacitor/android : 5.0.5
@capacitor/core : 5.0.5
@capacitor/ios : 5.0.5

Utility:

cordova-res : not installed globally
native-run : not installed globally

System:

NodeJS : v20.2.0 (/usr/bin/node)
npm : 9.7.1
OS : Linux 6.2
```

**Other Information:**

Admittedly, this *could* be seen as a `vite` issue, but I it's possible that they would consider rejecting everything after `--` as a security benefit.

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.