我已經與的WebPack其中進口模塊從另一種常見的存儲庫構成的角(2)的應用程序。問題4
所以,共同的資料庫有這樣的一個common.module.ts文件:
@NgModule({
imports: [...],
declarations: [...],
providers: [...],
exports: [...]
})
export class CommonModule {}
,然後在我的主要的應用程序,我在我的app.module.ts導入此
@NgModule({
imports: [
...
CommonModule,
],
declarations: [...],
providers: [...],
bootstrap: [AppComponent]
})
export class AppModule { }
這在Angular2中正常工作,但後來我試圖在我的主項目中遷移到Angular 4.0(不使用公共存儲庫,因爲其他存儲庫也沒有使用它)。 所以,我改變我的版本在我的package.json和重建,一切似乎很好,但後來當我在瀏覽器中加載應用程序,我得到這個
Uncaught Error: Unexpected value 'CommonModule' imported by the module 'AppModule'. Please add a @NgModule annotation.
任何人都知道這是怎麼回事? CommonModule已經使用@NgModule進行了聲明。 我檢查,以防node_modules並且有一些錯誤導入的文件,發現其中含有
...
export declare class CommonModule {}
但是這對我來說是罰款common_module.d.ts,這桶文件和裝飾已移出這裏。
任何想法?
你有沒有回滾到你以前的package.json前擦除node_modules? – Stanislasdrg
我擦除node_modules,又改版本角4和'''紗install'''。 – David
'CommonModule'也來自'@angular \ common',是不知怎的搞亂了?你有沒有嘗試重命名你的CommonModule? –