serve命令需要在Angular项目@ angular / cli @ 1.6.7中运行

时间:2019-07-15 05:09:05

标签: angular angular-cli

ng serve命令输入,得到上述错误。

  

serve命令需要在Angular项目中运行,但是找不到项目定义。

我已经尝试了所有StackOverflow答案,但无法解决 我的问题。

也是

npm start command
User @angular/cli@1.6.7

我的package.json文件:

{
      "name": "headerfooter",
      "version": "0.0.0",
      "license": "MIT",
      "scripts": {
        "ng": "ng",
        "start": "ng serve --host 0.0.0.0 --port 4200",
        "build": "ng build --prod",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e"
      },
      "private": true,
      "dependencies": {
        "@agm/core": "^1.0.0-beta.7",
        "@angular-package/change-detection": "^1.0.0",
        "@angular-package/core": "^1.0.1",
        "@angular/animations": "^8.1.1",
        "@angular/cdk": "^8.0.2",
        "@angular/common": "^8.1.1",
        "@angular/compiler": "^8.1.1",
        "@angular/core": "^8.1.1",
        "@angular/fire": "^5.2.1",
        "@angular/forms": "^8.1.1",
        "@angular/material": "^8.0.2",
        "@angular/platform-browser": "^8.1.1",
        "@angular/platform-browser-dynamic": "^8.1.1",
        "@angular/router": "^8.1.1",
        "@ng-bootstrap/ng-bootstrap": "^5.0.0",
        "@types/angular": "^1.6.55",
        "angular-alert-module": "^2.0.3",
        "angular-encryption-service": "^0.1.0",
        "angular-star-rating": "^4.0.0-beta.3",
        "angular5-social-login": "^1.0.9",
        "angularfire2": "^5.2.1",
        "bootstrap": "^4.3.1",
        "config": "^3.2.0",
        "core-js": "^3.1.4",
        "express": "^4.17.1",
        "firebase": "^6.3.0",
        "http": "0.0.0",
        "intl-tel-input": "^16.0.2",
        "jquery": "^3.4.1",
        "md-autocomplete": "0.0.1-alpha.1",
        "ng-bootstrap-to-bootstrap-3": "^0.7.0",
        "ng-recaptcha": "^4.3.0",
        "ng2-search-filter": "^0.5.1",
        "ng2-tel-input": "^2.0.3",
        "ng2-toastr": "^4.1.2",
        "ngx-echarts": "^4.2.1",
        "ngx-infinite-scroll": "^7.2.0",
        "ngx-intl-tel-input": "^2.2.1",
        "ngx-pagination": "^4.1.0",
        "ngx-show-hide-password": "^2.0.5",
        "path": "^0.12.7",
        "paytabs": "^2.2.0",
        "popper.js": "^1.15.0",
        "primeng": "^8.0.1",
        "rxjs": "^6.5.2",
        "rxjs-compat": "^6.5.2",
        "save": "^2.4.0",
        "sweetalert2": "^8.13.5",
        "tslib": "^1.9.0",
        "zone.js": "~0.9.1"
      },
      "devDependencies": {
        "@angular-devkit/build-angular": "~0.801.1",
        "@angular/cli": "^8.1.1",
        "@angular/compiler-cli": "^8.1.1",
        "@angular/language-service": "^8.1.1",
        "@types/googlemaps": "^3.37.0",
        "@types/jasmine": "^3.3.13",
        "@types/jasminewd2": "^2.0.6",
        "@types/node": "^12.6.2",
        "codelyzer": "^5.0.1",
        "jasmine-core": "~3.4.0",
        "jasmine-spec-reporter": "~4.2.1",
        "karma": "^4.2.0",
        "karma-chrome-launcher": "~3.0.0",
        "karma-coverage-istanbul-reporter": "^2.0.5",
        "karma-jasmine": "~2.0.1",
        "karma-jasmine-html-reporter": "^1.4.2",
        "protractor": "^6.0.0",
        "ts-node": "^8.3.0",
        "tslint": "^5.18.0",
        "typescript": "3.5.3"
      },
      "description": "This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.6.7.",
      "main": "app.js",
      "repository": {
        "type": "git",
        "url": ""
      },
      "author": "",
      "homepage": ""
    }

1 个答案:

答案 0 :(得分:0)

  

serve命令需要在Angular项目中运行,但是   找不到项目定义。

如果在适当的文件夹中未运行 ng serve 命令或 npm start 命令,通常会发生此错误。

请检查在其中正确运行命令的文件夹。如果您的项目位于D://demo/MyFirstProject中,则必须转到文件夹“ MyFirstProject”,然后运行命令。如果在文件夹“ demo”中运行命令,则会发生此错误。