端口xxx已被使用。使用“ --port”指定其他端口

时间:2019-08-19 10:10:19

标签: angular6

在Windows上,角度6: 我尝试使用许多端口,但没有任何端口工作。我总是收到错误消息:端口xxx已在使用中。使用'--port'指定其他端口。

我还研究并尝试了许多方法: -开启防火墙 -使用netstat查看端口,没有任何进程使用它们 -在package.json中更改其他版本的angular-cli,打字稿 但是对此没有解决方案。

这是我的package.json文件:

"dependencies": {
    "@angular-redux/store": "^9.0.0",
    "@angular/animations": "^6.1.0",
    "@angular/cdk": "^5.0.3",
    "@angular/common": "^6.1.0",
    "@angular/compiler": "^6.1.0",
    "@angular/core": "^6.1.0",
    "@angular/forms": "^6.1.0",
    "@angular/http": "^6.1.0",
    "@angular/material": "^5.0.3",
    "@angular/platform-browser": "^6.1.0",
    "@angular/platform-browser-dynamic": "^6.1.0",
    "@angular/router": "^6.1.0",
    "@mdi/font": "^3.6.95",
    "@ng-bootstrap/ng-bootstrap": "^4.0.2",
    "@ng-select/ng-select": "^2.14.0",
    "@types/file-saver": "^2.0.1",
    "adal-angular4": "^4.0.9",
    "babel-polyfill": "^6.23.0",
    "bootstrap": "^4.1.3",
    "classlist.js": "^1.1.20150312",
    "core-js": "^2.5.4",
    "d3": "^5.9.2",
    "daterangepicker": "^3.0.5",
    "fabric": "^3.1.0",
    "file-saver": "^2.0.2",
    "font-awesome": "^4.7.0",
    "highcharts": "^6.1.4",
    "jquery": "^3.4.1",
    "material-design-icons": "^3.0.1",
    "moment": "^2.24.0",
    "msal": "^1.0.1",
    "ng2-ckeditor": "^1.2.0",
    "ng2-file-upload": "^1.3.0",
    "ngrx-message-bus": "^1.0.4",
    "ngx-bootstrap": "^3.1.2",
    "ngx-color-picker": "^8.0.1",
    "ngx-image-cropper": "^1.3.9",
    "ngx-moment": "^3.4.0",
    "ngx-owl-carousel-o": "^1.1.5",
    "ngx-toastr": "^9.1.1",
    "node-sass": "^4.12.0",
    "redux": "^4.0.1",
    "rxjs": "6.3.3",
    "rxjs-compat": "^6.5.2",
    "tassign": "^1.0.0",
    "web-animations-js": "^2.3.1",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.7.0",
    "@angular/cli": "~6.1.0",
    "@angular/compiler-cli": "^6.1.0",
    "@angular/language-service": "^6.1.0",
    "@types/d3": "^5.7.2",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "^3.3.0",
    "jasmine-spec-reporter": "^4.2.1",
    "karma": "^3.1.3",
    "karma-chrome-launcher": "^2.2.0",
    "karma-cli": "^2.0.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "^2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "^5.4.1",
    "rxjs-tslint": "^0.1.6",
    "ts-node": "~5.0.1",
    "tslint": "^5.11.0",
    "typescript": "^2.9.2",
    "uuid": "^3.3.2"
  }
}
  

PS E:\ FSoft \ source \ Sample \ App.Client> ng服务

     

端口4200已在使用中。使用'--port'指定其他端口。

     

PS E:\ FSoft \ source \ Sample \ App.Client> ng服务-端口4201

     

端口4201已被使用。使用'--port'指定其他端口。

     

PS E:\ FSoft \ source \ Sample \ App.Client> ng服务-端口4216

     

端口4216已被使用。使用'--port'指定其他端口。

     

PS E:\ FSoft \ source \ Sample \ App.Client> ng服务-端口4305

     

端口4305已被使用。使用'--port'指定其他端口。

     

PS E:\ FSoft \ source \ Sample \ App.Client> ng服务--port 1234

     

端口1234已在使用中。使用'--port'指定其他端口。

     

PS E:\ FSoft \ source \ Sample \ App.Client> ng服务-端口9999

     

端口9999已在使用中。使用'--port'指定其他端口。

1 个答案:

答案 0 :(得分:0)

我已解决此问题。这是我的解决方法:

  • 删除 node_modules ,包括 package-lock.json
  • 运行 npm i ,然后遇到此错误:

      

    node_modules/@angular-redux/store/lib/src/components/ng-redux.d.ts(10,31)中的错误:错误> TS2420:类'NgRedux'错误地实现了接口   'ObservableStore'。    类型“ NgRedux”中缺少属性“ [Symbol.observable]”。

  • 我通过以下命令重新安装redux@4.0.1: npm i redux@4.0.1

  • 完成后,我开始 ng服务。可以。

感谢您的关注。