0

I am trying to build the Angular 5 project using --aot option and the build fails with the following error,

ERROR in ../node_modules/@angular/forms/esm5/forms.js Module not found: Error: Can't resolve '@angular/platform-browser' in '...PROJECT LOCATION.../node_modules/@angular/forms/esm5'

Angular version

Angular CLI: 1.7.4
Node: 8.11.1
OS: darwin x64
Angular: 5.2.10
... animations, common, compiler-cli, core, http
... language-service, router

@angular/cdk: 5.2.4
@angular/cli: 1.7.4
@angular/compiler: 5.2.11
@angular/forms: 5.2.0
@angular/material-moment-adapter: 8.0.1
@angular/material: 5.2.4
@angular/platform-browser-dynamic: 5.2.0
@angular/platform-browser: 5.2.0
@angular/platform-server: 8.1.2
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.4.2
webpack: 3.11.0

And the main.ts

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();
}

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

When I change it to bootstrapModule of platform-browser instead of platform-browser-dynamic build is successful but the app fails to render.

What needs to be done to compile using AOT?

ssilas777
  • 9,672
  • 4
  • 45
  • 68
PavanBhushan
  • 106
  • 2
  • 8

1 Answers1

0

Upgrade to typescript@2.6.2 will solve the issue

PavanBhushan
  • 106
  • 2
  • 8