1

I have a project that's being split apart using nx workspaces. Some of the workspaces give the error:

Required property 'main' is missing

when running the nx test command, and some don't. There seems to be nothing that would cause this in nx.json. Here is the relevant content of my 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"
}

It also gives this error when running "nx test" (on the default project).

John Davis
  • 11
  • 1
  • 4
  • is ngx build plus only configured in the "pricing" project? because it has the main attribute, is the error from this project? – Gui Seek Dec 03 '21 at 00:52

1 Answers1

0

Oh, ha! In posting my question, I noticed that I had the line:

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

That was setting up my tests for karma, even though I'm using Jest.

John Davis
  • 11
  • 1
  • 4