cipchk / ngx-highlight-js

Angular for syntax highlighting with highlight.js
https://cipchk.github.io/ngx-highlight-js/
MIT License
28 stars 4 forks source link

NullInjectorError: No provider for ElementRef! #5

Closed mtlynch closed 6 years ago

mtlynch commented 6 years ago
git clone https://github.com/mtlynch/ingredient-demo-frontend.git
cd ingredient-demo-frontend
git checkout syntax-highlight-angular6
npm install
ng serve

ng serve shows two warnings:

WARNING in ./node_modules/ngx-highlight-js/node_modules/@angular/core/fesm5/core.js
4911:15-36 Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/ngx-highlight-js/node_modules/@angular/core/fesm5/core.js
4923:15-102 Critical dependency: the request of a dependency is an expression

When I visit http://localhost:4200/docs, I see NullInjectorError: No provider for ElementRef! (full output)

This seems to be related to the fact that ngx-highlight-js is installing its own version of angular to node_modules:

$ ls node_modules/ngx-highlight-js/node_modules/
@angular  rxjs

If I manually delete the node_modules/ngx-highlight-js/node_modules/@angular directory then the page loads with no errors and applies correct syntax highlighting, but manually deleting from node_modules would obviously be problematic for real deployment scenarios.

mtlynch commented 6 years ago

Thanks!