离子服务命令找不到参数

Eli*_*l58 8 ionic-framework angular

我有一个有角度的项目,我想在移动设备上使用 ionic。我做到了ionic init

当我运行命令时ionic serve,我收到此错误:

> ng.cmd run app:serve --host=localhost --port=8100
[ng] Error: Unknown arguments: host, port

[ERROR] ng has unexpectedly closed (exit code 1).

        The Ionic CLI will exit. Please check any output above for error details.
Run Code Online (Sandbox Code Playgroud)

这是我的package.json

> ng.cmd run app:serve --host=localhost --port=8100
[ng] Error: Unknown arguments: host, port

[ERROR] ng has unexpectedly closed (exit code 1).

        The Ionic CLI will exit. Please check any output above for error details.
Run Code Online (Sandbox Code Playgroud)

如何修复主机/端口缺少参数?

在SimpleDev发表评论后,我在这里尝试了所有答案:

  • 使用npm install @ionic/app-scripts@latest --save-dev:该@ionic/app-scripts包已弃用,并且未更新为 Angular 14 或 15。运行它时,我得到Undefined variable standalone_static_library in binding.gyp while trying to load binding.gyp.
  • 删除node_modulesnpm install:不改变任何内容
  • 在这里卸载并重新安装 Angular/ionic cli :已经尝试过,并且没有改变任何东西
  • 复制了多个答案,其他的都一样:不行

小智 0

我希望这个解决方案可以帮助您:

  1. npm 缓存清理 --force

  2. npm 卸载 -g @angular/cli

  3. npm 卸载 -g @ionic/cli

  4. npm install -g @angular/cli

  5. npm install -g @ionic/cli