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.
这是我的package.json
文件:
{
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build:prod": "ng build --configuration production",
"watch": "ng build --watch --configuration development",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "^14.2.4",
"@angular/cdk": "^14.2.3",
"@angular/common": "^14.2.4",
"@angular/compiler": "^14.2.4",
"@angular/core": "^14.2.4",
"@angular/forms": "^14.2.4",
"@angular/material": "^14.2.3",
"@angular/platform-browser": "^14.2.4",
"@angular/platform-browser-dynamic": "^14.2.4",
"@angular/router": "^14.2.4",
"angular-material-dynamic-themes-eli": "^1.0.4",
"bootstrap": "^5.1.3",
"flag-icons": "^6.4.4",
"material-design-icons": "^3.0.1",
"ngx-editor": "^15.0.0",
"rxjs": "^7.4.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "^14.2.4",
"@angular/cli": "^14.2.4",
"@angular/compiler-cli": "^14.2.4",
"@types/jasmine": "^4.3.0",
"@types/node": "^18.7.23",
"jasmine-core": "^4.4.0",
"karma": "^6.4.1",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"tslib": "^2.3.1",
"typescript": "~4.8.4"
}
}
如何解决缺失主机/端口的参数?
在这里看到了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_modules
并重新安装npm install
:没有改变任何东西 - 在这里卸载并重新安装 Angular/Ionic CLI:已经尝试过,但没有改变任何东西
- 有些回答是复制的,其他的也一样:都不起作用
https://nodejs.org/en/
的 lts 版本?由于错误提到找不到主机,通常是 nodejs 创建主机而不是 ionic (angular),ionic (angular) 只是指向主机而不是创建它的人。因此,请检查您的 node js 是否已安装,如果已安装,请检查其是否正常工作(搜索此点),因为有时候 npm 可以工作但不是完全功能,因此请确保从 node js 中可以创建服务器,然后您就可以确定问题是否来自 nodejs。 - Mostafa Harbpython2
命令不起作用,即使我已经安装了 python2.7(可以使用py -2.7
)。 - Elikill58