【问题标题】:Angular 5 build with --aot Module not found - @angular/platform-browserAngular 5 build with --aot Module not found - @angular/platform-b​​rowser
【发布时间】:2019-07-25 20:13:43
【问题描述】:

我正在尝试使用 --aot 选项构建 Angular 5 项目,但构建失败并出现以下错误,

../node_modules/@angular/forms/esm5/forms.js 中的错误模块不是 发现:错误:无法解析 '...PROJECT 中的 '@angular/platform-b​​rowser' 位置.../node_modules/@angular/forms/esm5'

角度版本

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

还有 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));

当我将其更改为 platform-b​​rowserbootstrapModule 而不是 platform-b​​rowser-dynamic 构建成功但应用无法呈现.

使用 AOT 编译需要做什么?

【问题讨论】:

    标签: angular5 angular-forms angular-aot


    【解决方案1】:

    升级到 typescript@2.6.2 即可解决问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-02
      • 2019-04-01
      • 2021-04-23
      相关资源
      最近更新 更多