Angular2 CLI 构建异常:选择器 "app-root" 不匹配任何元素
Angular2 CLI build EXCEPTION : The selector "app-root" did not match any elements
从头开始,安装节点,打字,angular cli 和 运行 命令 sudo ng new plzstart --mobile 创建项目,然后使用 sudo ng build 构建它(在将 cd
执行到 plzstart
之后)。
选择器"app-root"没有匹配任何元素
构建命令抛出以下异常:
Apples-MacBook-Pro:plzstart apple$ sudo ng build
Password:
(node:45348) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
⠸ BuildingEXCEPTION: Error in :0:0
ORIGINAL EXCEPTION: The selector "app-root" did not match any elements
ORIGINAL STACKTRACE:
Error: The selector "app-root" did not match any elements
at new BaseException (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/facade/exceptions.js:17:23)
at NodeDomRenderer.DomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/dom/dom_renderer.js:79:23)
at DebugDomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/core/src/debug/debug_renderer.js:19:39)
at DebugAppView.AppView.selectOrCreateHostElement (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:88:41)
at DebugAppView._View_AppComponent_Host0.createInternal (AppComponent_Host.template.js:12:21)
at DebugAppView.AppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:66:21)
at DebugAppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:259:44)
at ComponentFactory.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/component_factory.js:143:36)
at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:314:44
at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:292:26
at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:281:29)
at Object.NgZoneImpl.inner.inner.fork.onInvoke (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:45:41)
at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:280:35)
at Zone.run (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:174:44)
at NgZoneImpl.runInner (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:76:71)
at NgZone.run (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone.js:223:66)
ERROR CONTEXT:
DebugContext {
_view:
DebugAppView {
clazz: [Function: _View_AppComponent_Host0],
componentType:
RenderComponentType {
id: 'knu-0',
templateUrl: '',
slotCount: 0,
encapsulation: 0,
styles: [] },
type: 0,
viewUtils:
ViewUtils {
_renderer: [Object],
_appId: 'knu',
_nextCompTypeId: 1,
sanitizer: DomSanitizationServiceImpl {} },
parentInjector:
ReflectiveInjector_ {
_debugContext: null,
_constructionCounter: 40,
_proto: [Object],
_parent: [Object],
_strategy: [Object] },
declarationAppElement: null,
cdMode: 2,
contentChildren: [],
viewChildren: [],
viewContainerElement: null,
cdState: 2,
destroyed: false,
ref: ViewRef_ { _view: [Circular] },
renderer: DebugDomRenderer { _delegate: [Object] },
staticNodeDebugInfos: [ [Object] ],
_currentDebugContext: [Circular],
context: {},
_hasExternalHostElement: true,
projectableNodes: [] },
_nodeIndex: 0,
_tplRow: 0,
_tplCol: 0 }
EXCEPTION: Error in :0:0
ORIGINAL EXCEPTION: The selector "app-root" did not match any elements
ORIGINAL STACKTRACE:
Error: The selector "app-root" did not match any elements
at new BaseException (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/facade/exceptions.js:17:23)
at NodeDomRenderer.DomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/dom/dom_renderer.js:79:23)
at DebugDomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/core/src/debug/debug_renderer.js:19:39)
at DebugAppView.AppView.selectOrCreateHostElement (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:88:41)
at DebugAppView._View_AppComponent_Host0.createInternal (AppComponent_Host.template.js:12:21)
at DebugAppView.AppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:66:21)
at DebugAppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:259:44)
at ComponentFactory.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/component_factory.js:143:36)
at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:314:44
at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:292:26
at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:281:29)
at Object.NgZoneImpl.inner.inner.fork.onInvoke (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:45:41)
at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:280:35)
at Zone.run (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:174:44)
at NgZoneImpl.runInner (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:76:71)
at NgZone.run (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone.js:223:66)
ERROR CONTEXT:
DebugContext {
_view:
DebugAppView {
clazz: [Function: _View_AppComponent_Host0],
componentType:
RenderComponentType {
id: 'knu-0',
templateUrl: '',
slotCount: 0,
encapsulation: 0,
styles: [] },
type: 0,
viewUtils:
ViewUtils {
_renderer: [Object],
_appId: 'knu',
_nextCompTypeId: 1,
sanitizer: DomSanitizationServiceImpl {} },
parentInjector:
ReflectiveInjector_ {
_debugContext: null,
_constructionCounter: 40,
_proto: [Object],
_parent: [Object],
_strategy: [Object] },
declarationAppElement: null,
cdMode: 2,
contentChildren: [],
viewChildren: [],
viewContainerElement: null,
cdState: 2,
destroyed: false,
ref: ViewRef_ { _view: [Circular] },
renderer: DebugDomRenderer { _delegate: [Object] },
staticNodeDebugInfos: [ [Object] ],
_currentDebugContext: [Circular],
context: {},
_hasExternalHostElement: true,
projectableNodes: [] },
_nodeIndex: 0,
_tplRow: 0,
_tplCol: 0 }
ngOnInit Error: { [Error: EXCEPTION: Error in :0:0
ORIGINAL EXCEPTION: The selector "app-root" did not match any elements
ORIGINAL STACKTRACE:
Error: The selector "app-root" did not match any elements
at new BaseException (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/facade/exceptions.js:17:23)
at NodeDomRenderer.DomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/dom/dom_renderer.js:79:23)
at DebugDomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/core/src/debug/debug_renderer.js:19:39)
at DebugAppView.AppView.selectOrCreateHostElement (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:88:41)
at DebugAppView._View_AppComponent_Host0.createInternal (AppComponent_Host.template.js:12:21)
at DebugAppView.AppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:66:21)
at DebugAppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:259:44)
at ComponentFactory.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/component_factory.js:143:36)
at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:314:44
at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:292:26
at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:281:29)
at Object.NgZoneImpl.inner.inner.fork.onInvoke (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:45:41)
at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:280:35)
at Zone.run (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:174:44)
at NgZoneImpl.runInner (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:76:71)
at NgZone.run (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone.js:223:66)
ERROR CONTEXT:
[object Object]]
_wrapperMessage: 'Error in :0:0',
_originalException:
{ Error: The selector "app-root" did not match any elements
at new BaseException (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/facade/exceptions.js:17:23)
at NodeDomRenderer.DomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/dom/dom_renderer.js:79:23)
at DebugDomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/core/src/debug/debug_renderer.js:19:39)
at DebugAppView.AppView.selectOrCreateHostElement (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:88:41)
at DebugAppView._View_AppComponent_Host0.createInternal (AppComponent_Host.template.js:12:21)
at DebugAppView.AppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:66:21)
at DebugAppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:259:44)
at ComponentFactory.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/component_factory.js:143:36)
at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:314:44
at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:292:26
at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:281:29)
at Object.NgZoneImpl.inner.inner.fork.onInvoke (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:45:41)
at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:280:35)
at Zone.run (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:174:44)
at NgZoneImpl.runInner (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:76:71)
at NgZone.run (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone.js:223:66)
message: 'The selector "app-root" did not match any elements',
stack: 'Error: The selector "app-root" did not match any elements\n at new BaseException (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/facade/exceptions.js:17:23)\n at NodeDomRenderer.DomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/dom/dom_renderer.js:79:23)\n at DebugDomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/core/src/debug/debug_renderer.js:19:39)\n at DebugAppView.AppView.selectOrCreateHostElement (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:88:41)\n at DebugAppView._View_AppComponent_Host0.createInternal (AppComponent_Host.template.js:12:21)\n at DebugAppView.AppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:66:21)\n at DebugAppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:259:44)\n at ComponentFactory.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/component_factory.js:143:36)\n at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:314:44\n at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:292:26\n at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:281:29)\n at Object.NgZoneImpl.inner.inner.fork.onInvoke (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:45:41)\n at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:280:35)\n at Zone.run (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:174:44)\n at NgZoneImpl.runInner (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:76:71)\n at NgZone.run (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone.js:223:66)' },
_originalStack: 'Error: The selector "app-root" did not match any elements\n at new BaseException (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/facade/exceptions.js:17:23)\n at NodeDomRenderer.DomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/dom/dom_renderer.js:79:23)\n at DebugDomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/core/src/debug/debug_renderer.js:19:39)\n at DebugAppView.AppView.selectOrCreateHostElement (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:88:41)\n at DebugAppView._View_AppComponent_Host0.createInternal (AppComponent_Host.template.js:12:21)\n at DebugAppView.AppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:66:21)\n at DebugAppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:259:44)\n at ComponentFactory.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/component_factory.js:143:36)\n at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:314:44\n at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:292:26\n at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:281:29)\n at Object.NgZoneImpl.inner.inner.fork.onInvoke (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:45:41)\n at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:280:35)\n at Zone.run (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:174:44)\n at NgZoneImpl.runInner (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:76:71)\n at NgZone.run (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone.js:223:66)',
_context:
DebugContext {
_view:
DebugAppView {
clazz: [Function: _View_AppComponent_Host0],
componentType: [Object],
type: 0,
viewUtils: [Object],
parentInjector: [Object],
declarationAppElement: null,
cdMode: 2,
contentChildren: [],
viewChildren: [],
viewContainerElement: null,
cdState: 2,
destroyed: false,
ref: [Object],
renderer: [Object],
staticNodeDebugInfos: [Object],
_currentDebugContext: [Circular],
context: {},
_hasExternalHostElement: true,
projectableNodes: [] },
_nodeIndex: 0,
_tplRow: 0,
_tplCol: 0 },
_wrapperStack: 'Error: Error in :0:0\n at ViewWrappedException.WrappedException [as constructor] (/Users/apple/PlzStart/node_modules/@angular/core/src/facade/exceptions.js:34:31)\n at new ViewWrappedException (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/exceptions.js:59:16)\n at DebugAppView._rethrowWithContext (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:306:23)\n at DebugAppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:262:18)\n at ComponentFactory.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/component_factory.js:143:36)\n at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:314:44\n at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:292:26\n at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:281:29)\n at Object.NgZoneImpl.inner.inner.fork.onInvoke (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:45:41)\n at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:280:35)\n at Zone.run (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:174:44)\n at NgZoneImpl.runInner (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:76:71)\n at NgZone.run (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone.js:223:66)\n at ApplicationRef_.run (/Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:290:14)\n at ApplicationRef_.bootstrap (/Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:312:21)\n at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:100:50' }
Rendering Document Error: TypeError: Cannot read property '0' of undefined
at /Users/apple/PlzStart/node_modules/angular2-universal/dist/node/bootloader.js:132:38
at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:281:29)
at Zone.run (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:174:44)
at /Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:529:58
at ZoneDelegate.invokeTask (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:314:38)
at Zone.runTask (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:214:48)
at drainMicroTaskQueue (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:432:36)
at process._tickCallback (internal/process/next_tick.js:103:7)
Built project successfully. Stored in "dist/".
关于这是什么原因的任何线索?
我在开始一个新项目后遇到了同样的问题:
ng new NAME --mobile
之后我做了这个:
- rm -fR NAME (完全删除项目文件夹并重新开始)
- ng new --mobile NAME --skip-npm (跳过npm步骤,稍后手动执行)
- cd 名称
- 从 0.101.5 更改 angular2-univeral 版本 在 package.json 到
"angular2-universal": "^0.100.3"
- npm install (现在我们手动执行npm)
- ng 构建
- ng 服务器
这次一切顺利。希望这对你也有帮助,让我知道,谢谢!
从头开始,安装节点,打字,angular cli 和 运行 命令 sudo ng new plzstart --mobile 创建项目,然后使用 sudo ng build 构建它(在将 cd
执行到 plzstart
之后)。
选择器"app-root"没有匹配任何元素
构建命令抛出以下异常:
Apples-MacBook-Pro:plzstart apple$ sudo ng build
Password:
(node:45348) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
⠸ BuildingEXCEPTION: Error in :0:0
ORIGINAL EXCEPTION: The selector "app-root" did not match any elements
ORIGINAL STACKTRACE:
Error: The selector "app-root" did not match any elements
at new BaseException (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/facade/exceptions.js:17:23)
at NodeDomRenderer.DomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/dom/dom_renderer.js:79:23)
at DebugDomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/core/src/debug/debug_renderer.js:19:39)
at DebugAppView.AppView.selectOrCreateHostElement (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:88:41)
at DebugAppView._View_AppComponent_Host0.createInternal (AppComponent_Host.template.js:12:21)
at DebugAppView.AppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:66:21)
at DebugAppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:259:44)
at ComponentFactory.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/component_factory.js:143:36)
at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:314:44
at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:292:26
at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:281:29)
at Object.NgZoneImpl.inner.inner.fork.onInvoke (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:45:41)
at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:280:35)
at Zone.run (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:174:44)
at NgZoneImpl.runInner (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:76:71)
at NgZone.run (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone.js:223:66)
ERROR CONTEXT:
DebugContext {
_view:
DebugAppView {
clazz: [Function: _View_AppComponent_Host0],
componentType:
RenderComponentType {
id: 'knu-0',
templateUrl: '',
slotCount: 0,
encapsulation: 0,
styles: [] },
type: 0,
viewUtils:
ViewUtils {
_renderer: [Object],
_appId: 'knu',
_nextCompTypeId: 1,
sanitizer: DomSanitizationServiceImpl {} },
parentInjector:
ReflectiveInjector_ {
_debugContext: null,
_constructionCounter: 40,
_proto: [Object],
_parent: [Object],
_strategy: [Object] },
declarationAppElement: null,
cdMode: 2,
contentChildren: [],
viewChildren: [],
viewContainerElement: null,
cdState: 2,
destroyed: false,
ref: ViewRef_ { _view: [Circular] },
renderer: DebugDomRenderer { _delegate: [Object] },
staticNodeDebugInfos: [ [Object] ],
_currentDebugContext: [Circular],
context: {},
_hasExternalHostElement: true,
projectableNodes: [] },
_nodeIndex: 0,
_tplRow: 0,
_tplCol: 0 }
EXCEPTION: Error in :0:0
ORIGINAL EXCEPTION: The selector "app-root" did not match any elements
ORIGINAL STACKTRACE:
Error: The selector "app-root" did not match any elements
at new BaseException (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/facade/exceptions.js:17:23)
at NodeDomRenderer.DomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/dom/dom_renderer.js:79:23)
at DebugDomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/core/src/debug/debug_renderer.js:19:39)
at DebugAppView.AppView.selectOrCreateHostElement (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:88:41)
at DebugAppView._View_AppComponent_Host0.createInternal (AppComponent_Host.template.js:12:21)
at DebugAppView.AppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:66:21)
at DebugAppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:259:44)
at ComponentFactory.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/component_factory.js:143:36)
at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:314:44
at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:292:26
at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:281:29)
at Object.NgZoneImpl.inner.inner.fork.onInvoke (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:45:41)
at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:280:35)
at Zone.run (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:174:44)
at NgZoneImpl.runInner (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:76:71)
at NgZone.run (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone.js:223:66)
ERROR CONTEXT:
DebugContext {
_view:
DebugAppView {
clazz: [Function: _View_AppComponent_Host0],
componentType:
RenderComponentType {
id: 'knu-0',
templateUrl: '',
slotCount: 0,
encapsulation: 0,
styles: [] },
type: 0,
viewUtils:
ViewUtils {
_renderer: [Object],
_appId: 'knu',
_nextCompTypeId: 1,
sanitizer: DomSanitizationServiceImpl {} },
parentInjector:
ReflectiveInjector_ {
_debugContext: null,
_constructionCounter: 40,
_proto: [Object],
_parent: [Object],
_strategy: [Object] },
declarationAppElement: null,
cdMode: 2,
contentChildren: [],
viewChildren: [],
viewContainerElement: null,
cdState: 2,
destroyed: false,
ref: ViewRef_ { _view: [Circular] },
renderer: DebugDomRenderer { _delegate: [Object] },
staticNodeDebugInfos: [ [Object] ],
_currentDebugContext: [Circular],
context: {},
_hasExternalHostElement: true,
projectableNodes: [] },
_nodeIndex: 0,
_tplRow: 0,
_tplCol: 0 }
ngOnInit Error: { [Error: EXCEPTION: Error in :0:0
ORIGINAL EXCEPTION: The selector "app-root" did not match any elements
ORIGINAL STACKTRACE:
Error: The selector "app-root" did not match any elements
at new BaseException (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/facade/exceptions.js:17:23)
at NodeDomRenderer.DomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/dom/dom_renderer.js:79:23)
at DebugDomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/core/src/debug/debug_renderer.js:19:39)
at DebugAppView.AppView.selectOrCreateHostElement (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:88:41)
at DebugAppView._View_AppComponent_Host0.createInternal (AppComponent_Host.template.js:12:21)
at DebugAppView.AppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:66:21)
at DebugAppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:259:44)
at ComponentFactory.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/component_factory.js:143:36)
at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:314:44
at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:292:26
at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:281:29)
at Object.NgZoneImpl.inner.inner.fork.onInvoke (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:45:41)
at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:280:35)
at Zone.run (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:174:44)
at NgZoneImpl.runInner (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:76:71)
at NgZone.run (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone.js:223:66)
ERROR CONTEXT:
[object Object]]
_wrapperMessage: 'Error in :0:0',
_originalException:
{ Error: The selector "app-root" did not match any elements
at new BaseException (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/facade/exceptions.js:17:23)
at NodeDomRenderer.DomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/dom/dom_renderer.js:79:23)
at DebugDomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/core/src/debug/debug_renderer.js:19:39)
at DebugAppView.AppView.selectOrCreateHostElement (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:88:41)
at DebugAppView._View_AppComponent_Host0.createInternal (AppComponent_Host.template.js:12:21)
at DebugAppView.AppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:66:21)
at DebugAppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:259:44)
at ComponentFactory.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/component_factory.js:143:36)
at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:314:44
at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:292:26
at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:281:29)
at Object.NgZoneImpl.inner.inner.fork.onInvoke (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:45:41)
at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:280:35)
at Zone.run (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:174:44)
at NgZoneImpl.runInner (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:76:71)
at NgZone.run (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone.js:223:66)
message: 'The selector "app-root" did not match any elements',
stack: 'Error: The selector "app-root" did not match any elements\n at new BaseException (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/facade/exceptions.js:17:23)\n at NodeDomRenderer.DomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/dom/dom_renderer.js:79:23)\n at DebugDomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/core/src/debug/debug_renderer.js:19:39)\n at DebugAppView.AppView.selectOrCreateHostElement (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:88:41)\n at DebugAppView._View_AppComponent_Host0.createInternal (AppComponent_Host.template.js:12:21)\n at DebugAppView.AppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:66:21)\n at DebugAppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:259:44)\n at ComponentFactory.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/component_factory.js:143:36)\n at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:314:44\n at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:292:26\n at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:281:29)\n at Object.NgZoneImpl.inner.inner.fork.onInvoke (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:45:41)\n at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:280:35)\n at Zone.run (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:174:44)\n at NgZoneImpl.runInner (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:76:71)\n at NgZone.run (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone.js:223:66)' },
_originalStack: 'Error: The selector "app-root" did not match any elements\n at new BaseException (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/facade/exceptions.js:17:23)\n at NodeDomRenderer.DomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/platform-browser/src/dom/dom_renderer.js:79:23)\n at DebugDomRenderer.selectRootElement (/Users/apple/PlzStart/node_modules/@angular/core/src/debug/debug_renderer.js:19:39)\n at DebugAppView.AppView.selectOrCreateHostElement (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:88:41)\n at DebugAppView._View_AppComponent_Host0.createInternal (AppComponent_Host.template.js:12:21)\n at DebugAppView.AppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:66:21)\n at DebugAppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:259:44)\n at ComponentFactory.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/component_factory.js:143:36)\n at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:314:44\n at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:292:26\n at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:281:29)\n at Object.NgZoneImpl.inner.inner.fork.onInvoke (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:45:41)\n at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:280:35)\n at Zone.run (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:174:44)\n at NgZoneImpl.runInner (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:76:71)\n at NgZone.run (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone.js:223:66)',
_context:
DebugContext {
_view:
DebugAppView {
clazz: [Function: _View_AppComponent_Host0],
componentType: [Object],
type: 0,
viewUtils: [Object],
parentInjector: [Object],
declarationAppElement: null,
cdMode: 2,
contentChildren: [],
viewChildren: [],
viewContainerElement: null,
cdState: 2,
destroyed: false,
ref: [Object],
renderer: [Object],
staticNodeDebugInfos: [Object],
_currentDebugContext: [Circular],
context: {},
_hasExternalHostElement: true,
projectableNodes: [] },
_nodeIndex: 0,
_tplRow: 0,
_tplCol: 0 },
_wrapperStack: 'Error: Error in :0:0\n at ViewWrappedException.WrappedException [as constructor] (/Users/apple/PlzStart/node_modules/@angular/core/src/facade/exceptions.js:34:31)\n at new ViewWrappedException (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/exceptions.js:59:16)\n at DebugAppView._rethrowWithContext (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:306:23)\n at DebugAppView.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/view.js:262:18)\n at ComponentFactory.create (/Users/apple/PlzStart/node_modules/@angular/core/src/linker/component_factory.js:143:36)\n at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:314:44\n at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:292:26\n at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:281:29)\n at Object.NgZoneImpl.inner.inner.fork.onInvoke (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:45:41)\n at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:280:35)\n at Zone.run (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:174:44)\n at NgZoneImpl.runInner (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone_impl.js:76:71)\n at NgZone.run (/Users/apple/PlzStart/node_modules/@angular/core/src/zone/ng_zone.js:223:66)\n at ApplicationRef_.run (/Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:290:14)\n at ApplicationRef_.bootstrap (/Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:312:21)\n at /Users/apple/PlzStart/node_modules/@angular/core/src/application_ref.js:100:50' }
Rendering Document Error: TypeError: Cannot read property '0' of undefined
at /Users/apple/PlzStart/node_modules/angular2-universal/dist/node/bootloader.js:132:38
at ZoneDelegate.invoke (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:281:29)
at Zone.run (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:174:44)
at /Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:529:58
at ZoneDelegate.invokeTask (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:314:38)
at Zone.runTask (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:214:48)
at drainMicroTaskQueue (/Users/apple/PlzStart/node_modules/zone.js/dist/zone-node.js:432:36)
at process._tickCallback (internal/process/next_tick.js:103:7)
Built project successfully. Stored in "dist/".
关于这是什么原因的任何线索?
我在开始一个新项目后遇到了同样的问题:
ng new NAME --mobile
之后我做了这个:
- rm -fR NAME (完全删除项目文件夹并重新开始)
- ng new --mobile NAME --skip-npm (跳过npm步骤,稍后手动执行)
- cd 名称
- 从 0.101.5 更改 angular2-univeral 版本 在 package.json 到
"angular2-universal": "^0.100.3"
- npm install (现在我们手动执行npm)
- ng 构建
- ng 服务器
这次一切顺利。希望这对你也有帮助,让我知道,谢谢!