首页 > 解决方案 > 无法使用最新的 Angular 版本打开旧的 Angular 项目?

问题描述

我刚刚安装了最新版本的 Node.js ( v14.16.1) 和 Angular ( 11.2)。

我们的 TA 给了我们 Angular 项目,但我不能ng sever在我的机器上使用它。我收到以下错误:

An unhandled exception occurred: No projects support the 'serve' target.
See "C:\Users\Miljan\AppData\Local\Temp\ng-hVo6jS\angular-errors.log" for further details.

当我打开 时angular-errors.log,我有以下输出:

[error] Error: No projects support the 'serve' target.
at ServeCommand.initialize (C:\Users\Miljan\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js:58:19)
at async ServeCommand.validateAndRun (C:\Users\Miljan\AppData\Roaming\npm\node_modules\@angular\cli\models\command.js:127:9)
at async Object.runCommand (C:\Users\Miljan\AppData\Roaming\npm\node_modules\@angular\cli\models\command-runner.js:204:24)
at async default_1 (C:\Users\Miljan\AppData\Roaming\npm\node_modules\@angular\cli\lib\cli\index.js:80:31)

在这里你可以下载TA 给我们的 Angular 项目。

下面是package.json来自 TA 的项目:

{
      "name": "blog-client",
      "version": "0.0.0",
      "license": "MIT",
      "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e"
      },
      "private": true,
      "dependencies": {
        "@angular/animations": "^5.0.0",
        "@angular/common": "^5.0.0",
        "@angular/compiler": "^5.0.0",
        "@angular/core": "^5.0.0",
        "@angular/forms": "^5.0.0",
        "@angular/http": "^5.0.0",
        "@angular/platform-browser": "^5.0.0",
        "@angular/platform-browser-dynamic": "^5.0.0",
        "@angular/router": "^5.0.0",
        "bootstrap": "^3.3.7",
        "core-js": "^2.4.1",
        "rxjs": "^5.5.2",
        "zone.js": "^0.8.14"
      },
      "devDependencies": {
        "@angular/cli": "1.5.0",
        "@angular/compiler-cli": "^5.0.0",
        "@angular/language-service": "^5.0.0",
        "@types/jasmine": "~2.5.53",
        "@types/jasminewd2": "~2.0.2",
        "@types/node": "~6.0.60",
        "codelyzer": "~3.2.0",
        "jasmine-core": "~2.6.2",
        "jasmine-spec-reporter": "~4.1.0",
        "karma": "~1.7.0",
        "karma-chrome-launcher": "~2.1.1",
        "karma-cli": "~1.0.1",
        "karma-coverage-istanbul-reporter": "^1.2.1",
        "karma-jasmine": "~1.1.0",
        "karma-jasmine-html-reporter": "^0.2.2",
        "protractor": "~5.1.2",
        "ts-node": "~3.2.0",
        "tslint": "~5.7.0",
        "typescript": "~2.4.2"
      }
    }

标签: node.jsangularangular-cli

解决方案


好的,我做到了。

第一npm installnpm run-script build最后ng serve

这有助于如何为较旧的 Angular 项目服务?


推荐阅读