Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular2 CLI build EXCEPTION : The selector "app-root" did not match any elements

Started from scratch, installed node, typings, the angular cli and ran the command sudo ng new plzstart --mobile to create the project, then built it using sudo ng build (after performing a cd into plzstart).

The selector "app-root" did not match any elements

The build command throws the following exception :

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/".

Any clue as to what is the cause of this ?

like image 912
Neville Katila Avatar asked Jun 15 '16 16:06

Neville Katila


1 Answers

I had the same issue after starting a new project with: ng new NAME --mobile after that I've done this:

  • rm -fR NAME (to remove project folder completely and start over)
  • ng new --mobile NAME --skip-npm (skip npm step and execute it manually later)
  • cd NAME
  • change the angular2-univeral version from 0.101.5 in package.json to "angular2-universal": "^0.100.3"
  • npm install (now we execute npm manually)
  • ng build
  • ng server

everything went well this time. I hope this will help you also, let me know, thanks!

like image 138
Cosmin Avatar answered Nov 15 '22 08:11

Cosmin