2017-01-10 73 views
0

我使用角度cli 1.0.0-beta.21,我觀察到當我生成一個組件時,它不再使用moduleId: module.id作爲相對路徑。而且,如果我嘗試使用它,它提供了一個錯誤:Angular2:moduleId不再需要?

Uncaught Error: moduleId should be a string in "Page1NinjaComponent". See link for more information.

組件

@Component({ 
    moduleId: module.id, 
    selector: 'app-page1-ninja', 
    templateUrl: 'page1-ninja.component.html', 
    styleUrls: ['page1-ninja.component.css'] 
}) 

現在不再需要了?

+0

你在tsconfig中使用commonjs模塊嗎? – echonax

+0

我看到'tsconfig.json'中設置:'「module」:「commonjs」' - 是的 – sTx

回答

0

如果構建應用程序作爲commonjs,模塊加載有諸如systemjswebpack它主要用於通過Angular CLI合適的包加載器。因此,有一種加載相對路徑的替代方法。有關更多信息,請參閱herehere

+0

所以angular-cli使用webpack的方式。只是爲了知道 - 應該怎樣處理moduleId呢? – sTx

+0

沒什麼,只要看看超鏈接的文檔,你會發現有一種替代方式,你不會再需要它了:),我不知道,也許你不應該使用commonjs。應該定製然後。 –

+1

是的,但我得到那個錯誤 – sTx