简体   繁体   English

npm 运行开始给出错误架构验证失败并出现错误:数据路径“”应该具有必需的属性'browserTarget'

[英]npm run start gives error Schema validation failed with the errors: Data path "" should have required property 'browserTarget'

I cloned a git repo (Angular ver 11, Single SPA) to my local machine.我将一个 git 存储库(Angular ver 11,Single SPA)克隆到我的本地机器上。 The whole team needs to maintain the same version as in the package.json.整个团队需要维护与 package.json 中相同的版本。

  1. First I executed the command npm install首先我执行命令npm install
  2. Then I gave npm run start然后我给npm run start

I am getting the below issue我收到以下问题

Schema validation failed with the following errors: Data path "" should have required property 'browserTarget'.架构验证失败,出现以下错误:数据路径“”应该具有必需的属性“browserTarget”。

Below is my package.json下面是我的 package.json

{
  "name": "integration",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "npm run build:single-spa:integration",
    "watch": "ng build --watch --configuration development",
    "test": "ng test",
    "lint": "ng lint",
    "build:single-spa:integration": "ng build integration --prod --deploy-url http://localhost:4220/",
    "serve:single-spa:integration": "ng s --project integration --disable-host-check --port 4220 --live-reload false"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "11.0.5",
    "@angular/cdk": "11.2.4",
    "@angular/common": "11.0.5",
    "@angular/compiler": "11.0.5",
    "@angular/core": "11.0.5",
    "@angular/forms": "11.0.5",
    "@angular/platform-browser": "11.0.5",
    "@angular/platform-browser-dynamic": "11.0.5",
    "@angular/router": "11.0.5",
    "@ngx-translate/core": "13.0.0",
    "@ngx-translate/http-loader": "6.0.0",
    "guid-typescript": "1.0.9",
    "karma-coverage-istanbul-reporter": "3.0.3",
    "primeicons": "4.1.0",
    "primeng": "11.3.0",
    "rxjs": "6.6.0",
    "single-spa": "5.3.4",
    "single-spa-angular": "4.9.2",
    "tslib": "2.0.0",
    "zone.js": "0.10.2"
  },
  "devDependencies": {
    "@angular-builders/custom-webpack": "11.1.0",
    "@angular-devkit/build-angular": "~0.1100.5",
    "@angular/cli": "~11.0.5",
    "@angular/compiler-cli": "~11.0.5",
    "@types/jasmine": "~3.6.0",
    "@types/node": "^12.11.1",
    "codelyzer": "^6.0.0",
    "jasmine-core": "~3.6.0",
    "jasmine-spec-reporter": "~5.0.0",
    "karma": "^5.1.1",
    "karma-chrome-launcher": "^3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-coverage-istanbul-reporter": "^3.0.3",
    "karma-jasmine": "^4.0.1",
    "karma-jasmine-html-reporter": "^1.5.4",
    "protractor": "~7.0.0",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~4.0.2"
  }
}

**Update ** **更新 **

Below is the angular.json下面是angular.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "integration": {
      "projectType": "application",
      "schematics": {
        "@schematics/angular:application": {
          "strict": true
        }
      },
      "root": "",
      "sourceRoot": "src",
      "prefix": "integration",
      "architect": {
        "build": {
          "builder": "@angular-builders/custom-webpack:browser",
          "options": {
            "outputPath": "dist/integration",
            "index": "src/index.html",
            "main": "src/main.single-spa.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.app.json",
            "aot": false,
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": [],
            "customWebpackConfig": {
              "path": "extra-webpack.config.js",
              "libraryName": "integration",
              "libraryTarget": "umd"
            }
          },
          "configurations": {
            "production": {
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "500kb",
                  "maximumError": "1000mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "2kb",
                  "maximumError": "1000mb"
                }
              ],
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "outputHashing": "none"
            },
            "development": {
              "buildOptimizer": false,
              "optimization": false,
              "vendorChunk": true,
              "extractLicenses": false,
              "sourceMap": true,
              "namedChunks": true,
              "outputHashing": "none"
            }
          },
          "defaultConfiguration": "production"
        },
        "serve": {
          "builder": "@angular-builders/custom-webpack:dev-server",
          "configurations": {
            "production": {
              "browserTarget": "integration:build:production"
            },
            "development": {
              "browserTarget": "integration:build:development"
            }
          },
          "defaultConfiguration": "development"
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "integration:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "tsconfig.spec.json",
            "karmaConfig": "karma.conf.js",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": []
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "tsconfig.app.json",
              "tsconfig.spec.json",
              "e2e/tsconfig.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          },
          "e2e": {
            "builder": "@angular-devkit/build-angular:protractor",
            "options": {
              "protractorConfig": "e2e/protractor.conf.js",
              "devServerTarget": "integration:serve"
            },
            "configurations": {
              "production": {
                "devServerTarget": "integration:serve:production"
              }
            }
          }
        }
      }
    }
  },
  "defaultProject": "integration"
}

Please help me to resolve this issue请帮我解决这个问题

Edit - Additional Info编辑 - 附加信息

npm run build and ng test works fine with the same setup. npm run buildng test使用相同的设置工作正常。

You can try this one: https://stackoverflow.com/a/61080357/10832261 Since you cannot change versions in package.json, maybe node version could solve your issue: "check the Nodejs version support needed here: https://angular.io/guide/setup-local and check the installed version. If you are using the latest version of angular, you should be able to make it work with the latest version of Nodejs."您可以试试这个: https://stackoverflow.com/a/61080357/10832261由于您无法更改 package.json 中的版本,也许节点版本可以解决您的问题:“检查此处所需的 Nodejs 版本支持: https://angular。 io/guide/setup-local并检查安装的版本。如果您使用的是最新版本的 angular,您应该能够使其与最新版本的 Nodejs 一起使用。”

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何修复:运行 ng serve 或 npm start 时,数据路径“”在 Angular 8 中应该有必需的属性“browserTarget”错误 - How to fix: Data path “” should have required property 'browserTarget' error in Angular 8 when running ng serve or npm start “架构验证失败,出现以下错误:数据路径“”在运行“ng 测试”时应该具有必需的属性“karmaConfig”错误 - angular - "Schema validation failed with the following errors: Data path "" should have required property 'karmaConfig' error on running "ng test" - angular 架构验证失败并出现以下错误:数据路径“.builders['app-shell']”应该具有必需的属性“class” - Schema validation failed with the following errors: Data path ".builders['app-shell']" should have required property 'class' 架构验证失败并出现以下错误:数据路径“”应该具有必需的属性“tsConfig” - Schema validation failed with the following errors: Data path "" should have required property 'tsConfig' 错误:架构验证失败,出现以下错误:数据路径“.builders['app-shell']”应该具有必需的属性“class” - Error: Schema validation failed with the following errors: Data path ".builders['app-shell']" should have required property 'class' 离子问题:[ng]Schema 验证失败,出现以下错误:[ng]Data path".builders['app-shell']"should have required property 'class' - Ionic problem: [ng]Schema validation failed with the following errors:[ng]Data path".builders['app-shell']"should have required property 'class' 无法构建 APP - 架构验证失败并出现以下错误:数据路径“.builders['cordova-build']”应该具有必需的属性“class” - Unable to build APP - Schema validation failed with the following errors: Data path ".builders['cordova-build']" should have required property 'class' Error: Schema validation failed with the following errors: Data path "" should NOT have additional properties(project) - Error: Schema validation failed with the following errors: Data path "" should NOT have additional properties(project) Angular 架构验证失败并出现以下错误:数据路径“”不应具有其他属性(rebaseRootRelativeCssUrls - Angular Schema validation failed with the following errors: Data path “” should NOT have additional properties(rebaseRootRelativeCssUrls Angular 12:架构验证失败,出现以下错误:数据路径“”不应具有其他属性(inlineStyleLanguage) - Angular 12: Schema validation failed with the following errors: Data path "" should NOT have additional properties(inlineStyleLanguage)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM