3

All of a sudden my angular code when built and deployed to the IIS server, I am getting Invalid ng target error with blank page. I am unable to figure out what has been changed. I have multiple envt files and in this case I am building with my dev environment file. This was working until mid may and all of a sudden it stopped working. I need help in trying to figure out the issue and how to fix it.

Error:main.b4e380d80b32ac5b2622.js:formatted:57352 Error: Invalid ng target
    at Ka (main.b4e380d80b32ac5b2622.js:formatted:6629)
    at Qa (main.b4e380d80b32ac5b2622.js:formatted:6635)
    at main.b4e380d80b32ac5b2622.js:formatted:10927
    at t.get [as listeners] (main.b4e380d80b32ac5b2622.js:formatted:10950)
    at e.listen (main.b4e380d80b32ac5b2622.js:formatted:12918)
    at $p (main.b4e380d80b32ac5b2622.js:formatted:11482)
    at wh (main.b4e380d80b32ac5b2622.js:formatted:11936)
    at yh (main.b4e380d80b32ac5b2622.js:formatted:11890)
    at hf (main.b4e380d80b32ac5b2622.js:formatted:12756)
    at Object.Nh [as createRootView] (main.b4e380d80b32ac5b2622.js:formatted:12392)

Here is the build dev configuration in angular.json `

"configurations": {
            "dev": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.dev.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "budgets": [
                {
                  "type": "initial",
                  "maximumWarning": "2mb",
                  "maximumError": "5mb"
                },
                {
                  "type": "anyComponentStyle",
                  "maximumWarning": "6kb",
                  "maximumError": "10kb"
                }
              ]
            },`

Here is the configurations section for the project

 "configurations": {
            "production": {
              "browserTarget": "myproject:build:production"
            },
            "dev": {
              "browserTarget": "myproject:build:dev"
            },

Here is the tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "module": "esnext",
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "ES5",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  },
  "angularCompilerOptions": {
    "fullTemplateTypeCheck": true,
    "strictInjectionParameters": true
  }
}

High level error seem to be coming from main.ts at platformBrowserDynamic().bootstrapModule(AppModule) .catch(err => console.error(err));

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

if (environment.production) {
  enableProdMode();
  if (window) {
    window.console.debug=function(){};
  }
}

platformBrowserDynamic().bootstrapModule(AppModule)
  .catch(err => console.error(err));
10
  • What version of Angular are you using? And can you post the code that is using it? Commented Jun 7, 2021 at 15:35
  • Angular CLI: 8.3.26 Angular: 8.2.14 Commented Jun 7, 2021 at 15:43
  • you recently upgraded to 8? or was it always 8? Commented Jun 7, 2021 at 15:45
  • 1
    using ng build? or ng build --watch? Commented Jun 7, 2021 at 15:46
  • 3
    try delete "node_models" and run "npm install" Commented Aug 6, 2021 at 13:10

1 Answer 1

1

As mentioned by @RDyego, I found that to be the same fix.

Start a refresh with node_modules.

I don't know if this other point had an impact but I stopped the various packages from getting updates by removing "^" and "~".

Since I knew it had previously worked I wondered if the newer versions had broken something.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.