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

未关闭
#5,020 1 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
typescript, vite
领域
cli

调研方向

从 package.json 中的 scripts 开始,并在 npmClientpnpm 时跟踪 ionic capacitor run android --livereload --external 入口点。使用 pnpm 和 Vite 重现该命令,然后验证 host 和 port 参数在没有额外 -- 的情况下传递到 Vite,并且连接等待会结束。

由索引模型根据 Issue 内容生成。

描述

triage

Description:

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

> 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:

❯ 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
{
	"name": "Hello World",
	"integrations": {
		"capacitor": {}
	},
	"type": "custom",
	"npmClient": "pnpm"
}
  1. Set these scripts in package.json
"dev:android": "ionic capacitor run android --livereload --external",
"ionic:serve": "vite dev",
  1. Run pnpm dev:android

Output:

My ionic info:

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.

主要语言
TypeScript
星标
2k
派生
681
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ionic-team/ionic-cli 的其他 Issue

查看 ionic-team/ionic-cli 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。