0

I upgraded my angular application from 6 to 13. I am able to compiler successfully thru ng build. However when I launch the application, I get 'JIT compiler unavailable' error. I figured out this will be caused if we don't bootstap the module either through '@angular/platform-browser-dynamic' or 'importing "@angular/compiler";'

But my main.js file below, bootstraps the module 'platformBrowserDynamic().bootstrapModule(AppModule)' . I also added import '@angular/compiler'; Still doesn't work. I am using "@angular/platform-browser-dynamic": "^13.2.0" in package.json

Any clues how to fix it.

main.js

import '@angular/compiler';
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from 'src/app/app.module';
import { environment } from 'src/environments/environment';

if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule)
  .catch(err => console.error(err));

Error when we launch the application: VM156 main.js:1 Uncaught Error: JIT compiler unavailable at yr (VM156 main.js:1:1987559) at Mk.get (VM156 main.js:1:2101936) at rn (VM156 main.js:1:1973608) at new kx (VM156 main.js:1:2084627) at aC (VM156 main.js:1:2118586) at o.bootstrapModule (VM156 main.js:1:2120630) at 7589 (VM156 main.js:1:1365219) at t (runtime.js:1:143) at VM156 main.js:1:2141515 at n (runtime.js:1:1550)

package.json

{
  "name": "pn-afrontapp",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "postinstall": "ngcc"
  },
  "private": true,
  "dependencies": {
    "@angular-slider/ngx-slider": "^2.0.4",
    "@angular/animations": "^13.2.0",
    "@angular/cdk": "^13.2.0",
    "@angular/common": "^13.2.0",
    "@angular/compiler": "^13.2.0",
    "@angular/core": "^13.2.0",
    "@angular/forms": "^13.2.0",
    "@angular/material": "^13.0.2",
    "@angular/material-moment-adapter": "^13.2.0",
    "@angular/platform-browser": "^13.2.0",
    "@angular/platform-browser-dynamic": "^13.2.0",
    "@angular/router": "^13.2.0",
    "@ngrx/effects": "^13.0.2",
    "@ngrx/store": "^13.0.2",
    "core-js": "^2.5.4",
    "crypto-js": "^3.1.9-1",
    "file-saver": "^2.0.0",
    "lodash": "^4.17.11",
    "moment": "^2.22.2",
    "ng-busy": "13.1.0",
    "ngx-spinner": "13.1.0",
    "rxjs": "^6.6.7",
    "zone.js": "0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "13.2.0",
    "@angular/cli": "^13.2.0",
    "@angular/compiler-cli": "^13.1.3",
    "@angular/language-service": "^13.1.3",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "angular2-cookie": "^1.2.6",
    "codelyzer": "6.0.2",
    "jasmine-core": "4.3.0",
    "jasmine-spec-reporter": "7.0.0",
    "karma": "6.4.0",
    "karma-chrome-launcher": "3.1.1",
    "karma-coverage-istanbul-reporter": "3.0.3",
    "karma-jasmine": "5.1.0",
    "karma-jasmine-html-reporter": "2.0.0",
    "lodash": "^4.17.11",
    "sass": "^1.54.3",
    "ts-node": "~7.0.0",
    "tslint": "~5.11.0",
    "typescript": "^4.5.5"
  }
}

angular.json (part of it)

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "cli": {
    "cache": {
      "enabled": false
    }
  },
  "newProjectRoot": "projects",
  "projects": {
    "myapplication": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist",
            "index": "src/index.html",
            "baseHref": "/myapplication/",
            "deployUrl":"/myapplication/",
            "main": "main.ts",
            "polyfills": "polyfills.ts",
            "tsConfig": "tsconfig.app.json",
    
  "defaultProject": "myapplication"
}
user1015388
  • 1,283
  • 4
  • 25
  • 45
  • is `node_modules` and `package-lock.json` deleted and reinstalled? – Naren Murali Sep 10 '22 at 04:51
  • Does this answer your question? [JIT compiler unavailable after angular update](https://stackoverflow.com/questions/68798086/jit-compiler-unavailable-after-angular-update) – Naren Murali Sep 10 '22 at 04:53
  • @NarenMurali, yes I tried that, deleting the node-modules and also tried those options in the link you gave – user1015388 Sep 10 '22 at 17:14

0 Answers0