角度依赖或版本问题。怎么解决?

问题描述 投票:0回答:1

您能帮我合并下面项目依赖项的版本吗(请不要使用版本 17,而应使用旧版本)!

这是我的

package.json
文件:

"dependencies": {
    "@angular/animations": "^15.0.0",
    "@angular/common": "^15.2.9",
    "@angular/compiler": "^15.0.0",
    "@angular/core": "^15.0.0",
    "@angular/forms": "^15.0.0",
    "@angular/platform-browser": "^15.0.0",
    "@angular/platform-browser-dynamic": "^15.0.0",
    "@angular/platform-server": "^15.0.0",
    "@angular/router": "^15.0.0",
    "@angular/ssr": "15.0.0",
    "express": "^4.18.2",
    "rxjs": "~7.5.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.12.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^15.0.0",
    "@angular/cli": "15.0.0",
    "@angular/compiler-cli": "^15.0.0",
    "@types/express": "^4.17.17",
    "@types/jasmine": "~4.3.0",
    "@types/node": "^18.18.0",
    "jasmine-core": "~4.5.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.0.0",
    "typescript": "~4.8.2"
  }

这是我的

angular.json
文件:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "innoteq-angular-frontend": {
      "projectType": "application",
      "schematics": {
        "@schematics/angular:component": {
          "standalone": false
        },
        "@schematics/angular:directive": {
          "standalone": false
        },
        "@schematics/angular:pipe": {
          "standalone": false
        }
      },
      "root": "",
      "sourceRoot": "src",
      "prefix": "app",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:application",
          "options": {
            "outputPath": "dist/innoteq-angular-frontend",
            "index": "src/index.html",
            "browser": "src/main.ts",
            "polyfills": [
              "zone.js"
            ],
            "tsConfig": "tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": [],
            "server": "src/main.server.ts",
            "prerender": true,
            "ssr": {
              "entry": "server.ts"
            }
          },
          "configurations": {
            "production": {
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "500kb",
                  "maximumError": "1mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "2kb",
                  "maximumError": "4kb"
                }
              ],
              "outputHashing": "all"
            },
            "development": {
              "optimization": false,
              "extractLicenses": false,
              "sourceMap": true
            }
          },
          "defaultConfiguration": "production"
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "configurations": {
            "production": {
              "buildTarget": "innoteq-angular-frontend:build:production"
            },
            "development": {
              "buildTarget": "innoteq-angular-frontend:build:development"
            }
          },
          "defaultConfiguration": "development"
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "buildTarget": "innoteq-angular-frontend:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "polyfills": [
              "zone.js",
              "zone.js/testing"
            ],
            "tsConfig": "tsconfig.spec.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": []
          }
        }
      }
    }
  },
  "cli": {
    "analytics": "cd2554c4-9eb4-45d2-8e67-fc281fc1033e"
  }
}

错误信息:

Schema validation failed with the following errors:
  Data path "" must have required property 'browserTarget'.

我在

angular.json
中尝试了无数版本和修改。他们都没有找到解决方案。

angular
1个回答
0
投票

该问题通常是由于 package.json 文件中的版本不匹配造成的。

在我的 Angular 7 应用程序中,我已将 "@angular-devkit/build-angular": "^0.800.2" 更改为 "@angular-devkit/build-angular": "~0.7.0"。

然后我执行以下步骤 删除节点模块 删除 package-lock.json npm 我

旁白:小心使用^。如果使用的包发生重大变化,您的工作代码将来可能无法工作。

或 从 angular.json 文件中删除这两行:

"vendorSourceMap":"true", “evalSourceMap”:“true”。

© www.soinside.com 2019 - 2024. All rights reserved.