Angular4 Prod构建错误 - BROWSER_SANITIZATION_PROVIDERS

时间:2017-03-29 08:24:46

标签: angular

运行以下构建命令

ng build --prod --aot 

收到以下错误(标准ng版本有效)

  

非法国家的错误:没有成员的符号,但得到了   {"文件路径":" d:/Projects/app/node_modules/@angular/platform-b​​rowser/platform-b​​rowser.d.ts","名称&#34 ;: "的 platform_browser_private ""会员":[" BROWSER_SANITIZATION_PROVIDERS"]}

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';

import { AppComponent } from './app.component';
import { NavBarComponent } from './navbar.component';
import { FooterComponent } from './footer.component';
import { MainComponent } from './main.component';

//Services
import { ProductService } from './services/product.service';
import { CategoryService } from './services/category.service';

//Pages
import { SubscriptionComponent } from './subscription/subscription.component';
import { ProductsComponent } from './products/products.component';
import { ProductComponent } from './product/product.component';
import { FrontpageHeaderComponent } from './frontpage-header.component';

//Global
import { RouterModule } from '@angular/router';
import { HeaderSecondLevelComponent } from './header-second-level.component';
import { NodeModule } from 'angular2-platform-node'
import { AppRoutingModule } from './app-routing.module';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

//Angular Material
import { MaterialModule } from '@angular/material';
import 'hammerjs';


@NgModule({
  declarations: [
    AppComponent,
    NavBarComponent,
    FooterComponent,
    MainComponent,
    SubscriptionComponent,
    ProductsComponent,
    ProductComponent,
    FrontpageHeaderComponent,
    HeaderSecondLevelComponent,
  ],
  entryComponents: [],
  imports: [
    BrowserModule,
    FormsModule,
    [MaterialModule],
    HttpModule,
    AppRoutingModule,
    BrowserAnimationsModule
  ],
  providers: [ProductService, CategoryService, BrowserModule],
  bootstrap: [AppComponent]
})
export class AppModule { }

1 个答案:

答案 0 :(得分:2)

为了解决这个问题,我从角度CLI安装指南运行了以下命令,现在我得到一个干净的prod aot build。

注意:我认为修复问题的部分是删除所有模块以便刷新它们,确保部件正确运行并且文件没有被锁定等等,这样你就可以获得干净的刷新。

npm uninstall -g angular-cli
npm uninstall --save-dev angular-cli

要将Angular CLI更新为新版本,您必须同时更新全局包和项目的本地包。

全球包装:

npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@latest

本地项目包:

rm -rf node_modules dist # use rmdir /S/Q node_modules dist in Windows Command Prompt; use rm -r -fo node_modules,dist in Windows PowerShell
npm install --save-dev @angular/cli@latest
npm install