question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Electron Forge + Angular 4 breaks with `'anonymous' is not a known element`

See original GitHub issue
  • I have read the contribution documentation for this project.
  • I agree to follow the code of conduct that this project follows, as appropriate.
  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Please describe your issue:

I’ve got a fresh install of Electron Forge with the angular2 template. I bumped the Angular dependencies to ^4.3.1, zone.js to ^0.8.14 and added hammerjs to package.json (to use Angular 4 material components).

I then added the source of a functional NG4 app in the src/app directory.

When running electron-forge start the console output is correct and the app starts, but the DevTools show this error:

Unhandled Promise rejection: Template parse errors:
'anonymous' is not a known element:
1. If 'anonymous' is an Angular component, then verify that it is part of this module.
2. To allow any element add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("tin\Desktop\ef-ng\node_modules\electron-compile\lib\protocol-hook.js:216:25)
    at Generator.next ([ERROR ->]<anonymous>)
    at step (C:\Users\Quentin\Desktop\ef-ng\node_modules\electron-compile\lib\protocol-h"): ng:///C:/Users/Quentin/Desktop/ef-ng/src/app/app.component.html@4:23

Here’s how my app.component.html looks:

<app-main-toolbar></app-main-toolbar>
<app-tree-item-tabs></app-tree-item-tabs>
<app-search-view *ngIf="appState.searchIsVisible"></app-search-view>
<app-media-view *ngIf="appState.activeMedia" [media]="appState.activeMedia"></app-media-view>

If I replace it with this, then it runs OK (but of course this is not what I’m looking for):

<app-main-toolbar></app-main-toolbar>
<app-tree-item-tabs></app-tree-item-tabs>
<app-search-view></app-search-view>

Notice I removed the app-media-view component and the *ngIf on the app-search-view one. I used to use a trick adding moduleId : module.id.split('\\').join('/'), to my @Component declarations, but that doesn’t work here.

I’m really stuck here. Any idea? Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
justindujardincommented, Dec 15, 2017

@ebordon thanks, that pointed me in the right direction. Also be on the lookout for a missing reference to moduleId in your components.

In my case I had this:

@Component({
  selector: 'pv-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.css']
})
export class HomeComponent {}

But I needed to add moduleId so the template lookup could happen in the proper subdirectory of my project.

@Component({
  moduleId: module.id,
  selector: 'pv-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.css']
})
export class HomeComponent {
}
1reaction
ebordoncommented, Aug 22, 2017

This is probably a bad reference to a template. Check the routes in your Component declaration. May be there is a typo or something like that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Electron Forge + Angular 4 breaks with `'anonymous' is not a ...
I've got a fresh install of Electron Forge with the angular2 template. I bumped the Angular dependencies to ^4.3.1 , zone.js to ^0.8.14...
Read more >
is not a known element · Issue #43121 · angular ... - GitHub
error NG8001: 'app-button' is not a known element: 1. If 'app-button' is an Angular component, then verify that it is part of this...
Read more >
Angular + Electron - App breaks on refresh or change-angular.js
Coding example for the question Angular + Electron - App breaks on refresh ... Electron Forge + Angular 4 breaks with `'anonymous' is...
Read more >
How to create an Electron app using Angular and SQLite3.
First install TypeORM. $ npm install typeorm --save. We will be following the TypeORM guide for creating schema here. When finished the file...
Read more >
Bug listing with status UNCONFIRMED as at 2022/12/24 17 ...
... Bug:375311 - "equery list - does not show status for packages in ... type has incomplete element type" status:UNCONFIRMED resolution: severity:normal ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found