0

我有一个使用 nx 工作区拆分的项目。一些工作区给出了错误:

Required property 'main' is missing

运行 nx test 命令时,有些没有。在 nx.json 中似乎没有什么会导致这种情况。这是我的angular.json的相关内容:

{
  "version": 1,
  "cli": {
    "defaultCollection": "@nrwl/angular",
    "analytics": false
  },
  "schematics": {
    "@nrwl/angular": {
      "application": {
        "linter": "eslint"
      },
      "library": {
        "linter": "eslint"
      },
      "storybook-configuration": {
        "linter": "eslint"
      }
    },
    "@nrwl/angular:application": {
      "style": "scss",
      "linter": "eslint",
      "unitTestRunner": "jest",
      "e2eTestRunner": "cypress"
    },
    "@nrwl/angular:library": {
      "style": "scss",
      "linter": "eslint",
      "unitTestRunner": "jest"
    },
    "@nrwl/angular:component": {
      "style": "scss"
    }
  },
  "newProjectRoot": "apps",
  "projects": {
    "pricing": {
      "projectType": "application",
      "root": "apps/pricing",
      "sourceRoot": "apps/pricing/src",
      "prefix": "trade-ops",
      "architect": {
        "build": {
          "builder": "ngx-build-plus:browser",
          "options": {
            "outputPath": "dist/apps/pricing",
            "index": "apps/pricing/src/index.html",
            "main": "apps/pricing/src/main.ts",
            "polyfills": "apps/pricing/src/polyfills.ts",
            "tsConfig": "apps/pricing/tsconfig.app.json",
            "aot": true,
            "assets": [
              {
                "glob": "*",
                "input": "libs/gav-shared/Assets/Icons/",
                "output": "assets/"
              },
              "apps/pricing/src/assets"
            ],
            "styles": ["apps/pricing/src/styles.scss"],
            "scripts": []
          },
          "configurations": {
            "production": {
              "optimization": true,
              "outputHashing": "none",
              "sourceMap": false,
              "namedChunks": false,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "10mb",
                  "maximumError": "25mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "6kb",
                  "maximumError": "10kb"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "ngx-build-plus:dev-server",
          "options": {
            "browserTarget": "pricing:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "pricing:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "pricing:build"
          }
        },
        "lint": {
          "builder": "@nrwl/linter:eslint",
          "options": {
            "lintFilePatterns": [
              "apps/pricing/src/**/*.ts",
              "apps/pricing/src/**/*.html"
            ]
          }
        },
        "test": {
          "builder": "ngx-build-plus:karma",
          "outputs": ["coverage/apps/pricing"],
          "options": {
            "jestConfig": "apps/pricing/jest.config.js",
            "passWithNoTests": true
          }
        }
      }
    },
    "pricing-e2e": {
      "root": "apps/pricing-e2e",
      "sourceRoot": "apps/pricing-e2e/src",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@nrwl/cypress:cypress",
          "options": {
            "cypressConfig": "apps/pricing-e2e/cypress.json",
            "tsConfig": "apps/pricing-e2e/tsconfig.e2e.json",
            "devServerTarget": "pricing:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "pricing:serve:production"
            }
          }
        },
        "lint": {
          "builder": "@nrwl/linter:eslint",
          "options": {
            "lintFilePatterns": ["apps/pricing-e2e/**/*.{js,ts}"]
          }
        }
      }
    },
// Other projects...
  },
  "defaultProject": "trade-operations"
}

运行“nx test”(在默认项目上)时也会出现此错误。

4

1 回答 1

0

哦,哈!在发布我的问题时,我注意到我有一行:

"builder": "ngx-build-plus:karma"

即使我使用的是 Jest,那也是在设置我的业力测试。

于 2021-06-07T13:17:51.680 回答