2016-12-30 35 views
0

我正在使用node.js服務器創建angular2客戶端應用程序。客戶端應用程序似乎工作得很好,這意味着:錯誤:「應用程序」與任何元素都不匹配

  • 我的所有請求都得到正確的響應。
  • 應用程序加載和按預期工作。

,但我得到這個錯誤在終端:

Error: The selector "app" did not match any elements 
    at DomRenderer.selectRootElement (/home/mu-user/Projects/my-app/dist/server/index.js:27126:23) 
    at selectOrCreateRenderHostElement (/home/mu-user/Projects/my-app/dist/server/index.js:15687:32) 
    at AppView._View_AppComponent_Host0.createInternal (/AppModule/AppComponent/host.ngfactory.js:12:16) 
    at AppView.create (/home/mu-user/Projects/my-app/dist/server/index.js:50916:21) 
    at ComponentFactory.create (/home/mu-user/Projects/my-app/dist/server/index.js:36656:36) 
    at ApplicationRef_.bootstrap (/home/mu-user/Projects/my-app/dist/server/index.js:23313:40) 
    at /home/mu-user/Projects/my-app/dist/server/index.js:23222:89 
    at Array.forEach (native) 
    at Object.Call (/home/mu-user/Projects/my-app/node_modules/es6-shim/es6-shim.js:307:14) 
    at Array.forEach (/home/mu-user/Projects/my-app/node_modules/es6-shim/es6-shim.js:1313:17) 

不中斷webpackhttp-server
問題是爲什麼我面對這個問題以及如何解決它?

+1

你可以包含一些主文件嗎?像index.html,引導文件,模塊.. – echonax

+0

這很可能是某種ngModule相關的問題,因爲你的應用程序不知道主要組件。你需要向我們展示一些我們可以幫助的代碼 –

+0

@echonax這個項目包含50多個組件,幾乎不可能添加整個代碼,但恢復到較舊的提交以獲得更簡單的版本,我注意到錯誤消失了。所以它也沒有幫助。 – Reyraa

回答

0

我在記錄中添加了這個答案,正如我在評論中所述。修復了對ngModule聲明列表中包含的模塊的引用,從而解決了此錯誤。
從錯誤消息的上下文中找出問題很棘手。而且由於代碼的複雜性,不可能包含實際的項目代碼,但是我試圖在這裏展示一個更簡單的版本,然後我想出了問題。

相關問題