FortAwesome / angular-fontawesome

Official Angular component for Font Awesome 5+
https://fontawesome.com
MIT License
1.49k stars 152 forks source link

Angular-fontawersome package issues with Angular 12. #306

Closed pelx closed 3 years ago

pelx commented 3 years ago

I installed FA in Angular 12 progect and it wouldn't render icons. I decided to try Angular 11 project.

I couldn't even install it.. The project uses tailwindcss. The log: `verbose cli [ 0 verbose cli 'C:\Program Files\nodejs\node.exe', 0 verbose cli 'C:\Users\Laura\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js', 0 verbose cli 'install', 0 verbose cli '@fortawesome/angular-fontawesome@0.8.2', 0 verbose cli '--quiet' 0 verbose cli ] 1 info using npm@7.14.0 2 info using node@v14.15.3 3 timing npm:load:whichnode Completed in 1ms 4 timing config:load:defaults Completed in 1ms 5 timing config:load:file:C:\Users\Laura\AppData\Roaming\npm\node_modules\npm\npmrc Completed in 1ms 6 timing config:load:builtin Completed in 1ms 7 timing config:load:cli Completed in 1ms 8 timing config:load:env Completed in 1ms 9 timing config:load:file:C:\dev_dev\atmovement.npmrc Completed in 1ms 10 timing config:load:project Completed in 1ms 11 timing config:load:file:C:\Users\Laura.npmrc Completed in 0ms 12 timing config:load:user Completed in 0ms 13 timing config:load:file:C:\Users\Laura\AppData\Roaming\npm\etc\npmrc Completed in 1ms 14 timing config:load:global Completed in 1ms 15 timing config:load:validate Completed in 0ms 16 timing config:load:credentials Completed in 1ms 17 timing config:load:setEnvs Completed in 1ms 18 timing config:load Completed in 8ms 19 timing npm:load:configload Completed in 9ms 20 timing npm:load:setTitle Completed in 0ms 21 timing npm:load:setupLog Completed in 1ms 22 timing npm:load:cleanupLog Completed in 2ms 23 timing npm:load:configScope Completed in 0ms 24 timing npm:load:projectScope Completed in 1ms 25 timing npm:load Completed in 14ms 26 timing config:load:flatten Completed in 3ms 27 timing arborist:ctor Completed in 1ms 28 timing idealTree:init Completed in 644ms 29 timing idealTree:userRequests Completed in 5ms 30 silly idealTree buildDeps 31 silly fetch manifest @fortawesome/angular-fontawesome@0.8.2 32 http fetch GET 304 https://registry.npmjs.org/@fortawesome%2fangular-fontawesome 1106ms (from cache) 33 silly fetch manifest @angular/core@~11.2.0 34 http fetch GET 304 https://registry.npmjs.org/@angular%2fcore 610ms (from cache) 35 silly fetch manifest rxjs@~6.6.0 36 http fetch GET 304 https://registry.npmjs.org/rxjs 1018ms (from cache) 37 silly fetch manifest zone.js@~0.11.3 38 http fetch GET 304 https://registry.npmjs.org/zone.js 1532ms (from cache) 39 silly fetch manifest @fortawesome/fontawesome-svg-core@^1.2.27 40 http fetch GET 304 https://registry.npmjs.org/@fortawesome%2ffontawesome-svg-core 13168ms (from cache) 41 silly fetch manifest @tailwindcss/colors@latest 42 http fetch GET 404 https://registry.npmjs.org/@tailwindcss%2fcolors 50ms 43 http fetch GET 404 https://registry.npmjs.org/@tailwindcss%2fcolors 66ms 44 silly placeDep ROOT @fortawesome/angular-fontawesome@0.8.2 OK for: atmovement@0.0.0 want: 0.8.2 45 silly placeDep ROOT @fortawesome/fontawesome-svg-core@1.2.35 OK for: @fortawesome/angular-fontawesome@0.8.2 want: ^1.2.27 46 silly placeDep ROOT @tailwindcss/colors@ OK for: atmovement@0.0.0 want: latest 47 silly fetch manifest @fortawesome/fontawesome-common-types@^0.2.35 48 http fetch GET 304 https://registry.npmjs.org/@fortawesome%2ffontawesome-common-types 151ms (from cache) 49 timing idealTree:#root Completed in 17744ms 50 timing idealTree:node_modules/@fortawesome/angular-fontawesome Completed in 0ms 51 silly placeDep ROOT @fortawesome/fontawesome-common-types@0.2.35 OK for: @fortawesome/fontawesome-svg-core@1.2.35 want: ^0.2.35 52 timing idealTree:node_modules/@fortawesome/fontawesome-svg-core Completed in 2ms 53 timing idealTree:node_modules/@fortawesome/fontawesome-common-types Completed in 0ms 54 timing idealTree:node_modules/@tailwindcss/colors Completed in 0ms 55 timing idealTree:buildDeps Completed in 17748ms 56 timing idealTree:fixDepFlags Completed in 25ms 57 timing idealTree Completed in 18422ms 58 timing command:install Completed in 18428ms 59 verbose stack HttpErrorGeneral: 404 Not Found - GET https://registry.npmjs.org/@tailwindcss%2fcolors - Not found 59 verbose stack at C:\Users\Laura\AppData\Roaming\npm\node_modules\npm\node_modules\npm-registry-fetch\check-response.js:134:15 59 verbose stack at processTicksAndRejections (internal/process/task_queues.js:93:5) 59 verbose stack at async Arborist.[nodeFromEdge] (C:\Users\Laura\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:934:19) 59 verbose stack at async Arborist.[buildDepStep] (C:\Users\Laura\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:880:11) 59 verbose stack at async Arborist.buildIdealTree (C:\Users\Laura\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\build-ideal-tree.js:218:7) 59 verbose stack at async Promise.all (index 1) 59 verbose stack at async Arborist.reify (C:\Users\Laura\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist\lib\arborist\reify.js:136:5) 59 verbose stack at async Install.install (C:\Users\Laura\AppData\Roaming\npm\node_modules\npm\lib\install.js:150:5) 60 verbose statusCode 404 61 verbose pkgid @tailwindcss/colors@latest 62 verbose cwd C:\dev_dev\atmovement 63 verbose Windows_NT 10.0.19042 64 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Users\Laura\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "install" "@fortawesome/angular-fontawesome@0.8.2" "--quiet" 65 verbose node v14.15.3 66 verbose npm v7.14.0 67 error code E404 68 error 404 Not Found - GET https://registry.npmjs.org/@tailwindcss%2fcolors - Not found 69 error 404 70 error 404 '@tailwindcss/colors@latest' is not in the npm registry. 71 error 404 You should bug the author to publish it (or use the name yourself!) 72 error 404 Note that you can also install from a 73 error 404 tarball, folder, http url, or git url. 74 verbose exit 1

`

devoto13 commented 3 years ago

I installed FA in Angular 12 progect and it wouldn't render icons.

Our tests indicate that this works. If you are unable to render an icon after following the instructions from the README I would suggest creating a fresh project with ng new, then add minimal code to reproduce the problem, push it on GitHub and share a link. Then we can investigate it and potentially make a fix.


As far as I can see from the log, angular-fontawesome was installed successfully:

50 timing idealTree:node_modules/@fortawesome/angular-fontawesome Completed in 0ms

But NPM failed to fetch the @tailwindcss/colors package:

68 error 404 Not Found - GET https://registry.npmjs.org/@tailwindcss%2fcolors - Not found

Which actually does not exist on the NPM: https://www.npmjs.com/search?q=%40tailwindcss%2Fcolors. If this is the private package then you may be missing some configurations on your machine.

pelx commented 3 years ago

In Angular 11 project (for which I sent log): Font awesome is not in node folder, it is not in package.json too.

In Angular 12 project Font awesome angular package was installed and all steps were performed. Icons don't render.

thank you for looking into it.

regards

Laura

ps Tailwindcss is an official package. I informed the owner.

------ Original Message ------ From: "Yaroslav Admin" @.> To: "FortAwesome/angular-fontawesome" @.> Cc: "Laura" @.>; "Author" @.> Sent: Sunday, 30 May, 21 At 15:48 Subject: Re: [FortAwesome/angular-fontawesome] Angular 11 installation failed (#306)

I installed FA in Angular 12 progect and it wouldn't render icons. Our tests indicate that this works. If you are unable to render an icon after following the instructions from the README https://github.com/FortAwesome/angular-fontawesome#usage I would suggest creating a fresh project with ng new, then add minimal code to reproduce the problem, push it on GitHub and share a link. Then we can investigate it and potentially make a fix. As far as I can see from the log, angular-fontawesome was installed successfully: 50 timing @./angular-fontawesome Completed in 0ms But NPM failed to fetch the @tailwindcss/colors package: 68 error 404 Not Found - GET @.%2fcolors @.***%2fcolors> - Not found Which actually does not exist on the NPM: https://www.npmjs.com/search?q=%40tailwindcss%2Fcolors https://www.npmjs.com/search?q=%40tailwindcss%2Fcolors . If this is the private package then you may be missing some configurations on your machine. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FortAwesome/angular-fontawesome/issues/306#issuecomment-851011791 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7ORGX5YLMI6VHBNBPCZ3LTQJF3FANCNFSM45ZGJTLQ .

pelx commented 3 years ago

I did run npm install again. FA wasn't installed.

Laura@DESKTOP-JDRT92A MINGW64 /c/dev/_dev/atmovement (master) $ npm install --save @fortawesome/fontawesome-free npm ERR! code E404 npm ERR! 404 Not Found - GET @.%2fcolors - Not found npm ERR! 404 npm ERR! 404 @*.**@*.***' is not in the npm registry. npm ERR! 404 You should bug the author to publish it (or use the name yourself!) npm ERR! 404 npm ERR! 404 Note that you can also install from a npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\Laura\AppData\Local\npm-cache_logs\2021-05-30T17_14_22_491Z-debug.log

Laura@DESKTOP-JDRT92A MINGW64 /c/dev/_dev/atmovement (master) $ npm --version 7.14.0

------ Original Message ------ From: "Yaroslav Admin" @.> To: "FortAwesome/angular-fontawesome" @.> Cc: "Laura" @.>; "Author" @.> Sent: Sunday, 30 May, 21 At 15:48 Subject: Re: [FortAwesome/angular-fontawesome] Angular 11 installation failed (#306)

I installed FA in Angular 12 progect and it wouldn't render icons. Our tests indicate that this works. If you are unable to render an icon after following the instructions from the README https://github.com/FortAwesome/angular-fontawesome#usage I would suggest creating a fresh project with ng new, then add minimal code to reproduce the problem, push it on GitHub and share a link. Then we can investigate it and potentially make a fix. As far as I can see from the log, angular-fontawesome was installed successfully: 50 timing @./angular-fontawesome Completed in 0ms But NPM failed to fetch the @tailwindcss/colors package: 68 error 404 Not Found - GET @.%2fcolors @.***%2fcolors> - Not found Which actually does not exist on the NPM: https://www.npmjs.com/search?q=%40tailwindcss%2Fcolors https://www.npmjs.com/search?q=%40tailwindcss%2Fcolors . If this is the private package then you may be missing some configurations on your machine. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FortAwesome/angular-fontawesome/issues/306#issuecomment-851011791 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7ORGX5YLMI6VHBNBPCZ3LTQJF3FANCNFSM45ZGJTLQ .

pelx commented 3 years ago

Hi,

After fiddling with my set up, I can render an icon in angular 11. The problem is with VSCode it still doesn't recognize

'fa-icon' is not a known element:

  1. If 'fa-icon' is an Angular component, then verify that it is part of this module.
  2. If 'fa-icon' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.ngtsc(-998001)

cheers

Laura

------ Original Message ------ From: "Yaroslav Admin" @.> To: "FortAwesome/angular-fontawesome" @.> Cc: "Laura" @.>; "Author" @.> Sent: Sunday, 30 May, 21 At 15:48 Subject: Re: [FortAwesome/angular-fontawesome] Angular 11 installation failed (#306)

I installed FA in Angular 12 progect and it wouldn't render icons. Our tests indicate that this works. If you are unable to render an icon after following the instructions from the README https://github.com/FortAwesome/angular-fontawesome#usage I would suggest creating a fresh project with ng new, then add minimal code to reproduce the problem, push it on GitHub and share a link. Then we can investigate it and potentially make a fix. As far as I can see from the log, angular-fontawesome was installed successfully: 50 timing @./angular-fontawesome Completed in 0ms But NPM failed to fetch the @tailwindcss/colors package: 68 error 404 Not Found - GET @.%2fcolors @.***%2fcolors> - Not found Which actually does not exist on the NPM: https://www.npmjs.com/search?q=%40tailwindcss%2Fcolors https://www.npmjs.com/search?q=%40tailwindcss%2Fcolors . If this is the private package then you may be missing some configurations on your machine. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FortAwesome/angular-fontawesome/issues/306#issuecomment-851011791 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7ORGX5YLMI6VHBNBPCZ3LTQJF3FANCNFSM45ZGJTLQ .

devoto13 commented 3 years ago

Either you forgot to add FontAwesomeModule to the imports of the correct module - see https://github.com/FortAwesome/angular-fontawesome/issues/275. Or it's an Angular language server glitch, which may get resolved by restarting your editor.

pelx commented 3 years ago

as I said before I run the same code on ng 11 and 12. Version 11 renders icons despite VSCode editor show the error.

ng 12 doesn't work. I can build the app, no errors, but it doesn't render and there are errors in the chrome console. I will switch to a different library.

thank you for your help.

core.js:14933 NG0304: 'fa-icon' is not a known element:

  1. If 'fa-icon' is an Angular component, then verify that it is part of this module.
  2. If 'fa-icon' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. logUnknownElementError @ core.js:14933 elementStartFirstCreatePass @ core.js:14784 ɵɵelementStart @ core.js:14820 ɵɵelement @ core.js:14899 CreditCardInputComponent_fa_icon_4_Template @ template.html:9 executeTemplate @ core.js:9575 renderView @ core.js:9379 createEmbeddedView @ core.js:23023 createEmbeddedView @ core.js:23154 create @ common.js:3672 enforceState @ common.js:3680 ngDoCheck @ common.js:3856 callHook @ core.js:2536 callHooks @ core.js:2495 executeInitAndCheckHooks @ core.js:2446 selectIndexInternal @ core.js:8424 ɵɵadvance @ core.js:8407 CreditCardInputComponent_Template @ template.html:14 executeTemplate @ core.js:9575 refreshView @ core.js:9441 refreshComponent @ core.js:10612 refreshChildComponents @ core.js:9238 refreshView @ core.js:9491 refreshComponent @ core.js:10612 refreshChildComponents @ core.js:9238 refreshView @ core.js:9491 refreshEmbeddedViews @ core.js:10566 refreshView @ core.js:9465 refreshComponent @ core.js:10612 refreshChildComponents @ core.js:9238 refreshView @ core.js:9491 renderComponentOrTemplate @ core.js:9555 tickRootContext @ core.js:10786 detectChangesInRootView @ core.js:10811 detectChanges @ core.js:22852 tick @ core.js:29642 (anonymous) @ core.js:29523 invoke @ zone.js:372 onInvoke @ core.js:28661 invoke @ zone.js:371 run @ zone.js:134 run @ core.js:28515 next @ core.js:29522 __tryOrUnsub @ Subscriber.js:183 next @ Subscriber.js:122 _next @ Subscriber.js:72 next @ Subscriber.js:49 next @ Subject.js:39 emit @ core.js:25931 checkStable @ core.js:28583 onHasTask @ core.js:28678 hasTask @ zone.js:426 _updateTaskCount @ zone.js:447 _updateTaskCount @ zone.js:274 runTask @ zone.js:195 drainMicroTaskQueue @ zone.js:582 Promise.then (async) scheduleMicroTask @ zone.js:565 scheduleTask @ zone.js:396 onScheduleTask @ zone.js:283 scheduleTask @ zone.js:386 scheduleTask @ zone.js:221 scheduleMicroTask @ zone.js:241 scheduleResolveOrReject @ zone.js:1266 resolvePromise @ zone.js:1204 (anonymous) @ zone.js:1120 webpackJsonpCallback @ bootstrap:25 (anonymous) @ components-components-module.js:1 Show 26 more frames core.js:10101 NG0303: Can't bind to 'icon' since it isn't a known property of 'fa-icon'.

------ Original Message ------ From: "Yaroslav Admin" @.> To: "FortAwesome/angular-fontawesome" @.> Cc: "Laura" @.>; "Author" @.> Sent: Monday, 31 May, 21 At 09:13 Subject: Re: [FortAwesome/angular-fontawesome] Angular 11 installation failed (#306)

Either you forgot to add FontAwesomeModule to the imports of the correct module - see #275 https://github.com/FortAwesome/angular-fontawesome/issues/275 . Or it's an Angular language server glitch, which may get resolved by restarting your editor. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FortAwesome/angular-fontawesome/issues/306#issuecomment-851301144 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7ORGSVZGCG4ESPXZEUFP3TQNAIZANCNFSM45ZGJTLQ .

pelx commented 3 years ago

Yaroslav,

I tried to create a new app in Angular 12 as you advised and got this message:

npm version 7.14.0 detected. The Angular CLI temporarily requires npm version 6 while upstream issues are addressed.

Please install a compatible version to proceed (npm install --global ***@***.***). For additional information and alternative workarounds, please see https://github.com/angular/angular-cli/issues/19957#issuecomment-775407654

I will downgrade my Angular version for a few months. Let someone else to find bugs:)

cheers Laura

------ Original Message ------ From: "Yaroslav Admin" @.> To: "FortAwesome/angular-fontawesome" @.> Cc: "Laura" @.>; "Author" @.> Sent: Monday, 31 May, 21 At 09:13 Subject: Re: [FortAwesome/angular-fontawesome] Angular 11 installation failed (#306)

Either you forgot to add FontAwesomeModule to the imports of the correct module - see #275 https://github.com/FortAwesome/angular-fontawesome/issues/275 . Or it's an Angular language server glitch, which may get resolved by restarting your editor. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FortAwesome/angular-fontawesome/issues/306#issuecomment-851301144 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7ORGSVZGCG4ESPXZEUFP3TQNAIZANCNFSM45ZGJTLQ .

devoto13 commented 3 years ago

I think that specific problem has been fixed in the latest @angular/cli version. So npm i -g @angular/cli@latest and ng new my-project should do the trick.

pelx commented 3 years ago

thank you. New app works with FA. The old app doesn't. I upgraded it to the @latest. The old app uses lazy loading, I will investigate. This may be the reason.

cheers

Laura

------ Original Message ------ From: "Yaroslav Admin" @.> To: "FortAwesome/angular-fontawesome" @.> Cc: "Laura" @.>; "Author" @.> Sent: Tuesday, 1 Jun, 21 At 09:35 Subject: Re: [FortAwesome/angular-fontawesome] Angular 11 installation failed (#306)

I think that specific problem has been fixed in the latest @angular/cli version. So npm i -g @@.*** and ng new my-project should do the trick. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FortAwesome/angular-fontawesome/issues/306#issuecomment-851940340 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7ORGQ2IRFMQQDTQAVHLO3TQSLUJANCNFSM45ZGJTLQ .

pelx commented 3 years ago

I found that I can use original FA package with no problems. It took 10 minuets to set up. Cant see the point of angular-fontawesome. Wasted a few hours and it still doesn't work.

my purpose was to develop similar to this 100angular https://github.com/PizzaPokerGuy/100-angular-challenges components using tailwindcss. The repo is using original FA. So will I. It seems angular-fontawesome is not needed at all. Just another layer to add complexity.

cheers

Laura

------ Original Message ------ From: "Yaroslav Admin" @.> To: "FortAwesome/angular-fontawesome" @.> Cc: "Laura" @.>; "Author" @.> Sent: Monday, 31 May, 21 At 09:13 Subject: Re: [FortAwesome/angular-fontawesome] Angular 11 installation failed (#306)

Either you forgot to add FontAwesomeModule to the imports of the correct module - see #275 https://github.com/FortAwesome/angular-fontawesome/issues/275 . Or it's an Angular language server glitch, which may get resolved by restarting your editor. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FortAwesome/angular-fontawesome/issues/306#issuecomment-851301144 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7ORGSVZGCG4ESPXZEUFP3TQNAIZANCNFSM45ZGJTLQ .

devoto13 commented 3 years ago

Of course. You are free to use whichever tool works best for you.

I'm going to close this issue as everything works as intended in the new project and the issue is not actionable without a reproduction of the problem.

pelx commented 3 years ago

Hi Yaroslav,

I only wanted to help. Your package doesn't work if an app has more than one module. I will replicate in a new app and send link to you.

regards

Laura

------ Original Message ------ From: "Yaroslav Admin" @.> To: "FortAwesome/angular-fontawesome" @.> Cc: "Laura" @.>; "Author" @.> Sent: Wednesday, 2 Jun, 21 At 19:56 Subject: Re: [FortAwesome/angular-fontawesome] Angular 11 installation failed (#306)

Of course. You are free to use whichever tool works best for you. I'm going to close this issue as everything works as intended in the new project and the issue is not actionable without a reproduction of the problem. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FortAwesome/angular-fontawesome/issues/306#issuecomment-853306623 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7ORGS47TUVYGIY2DVP3LTTQZ5ENANCNFSM45ZGJTLQ .

pelx commented 3 years ago

I have created a new project that doesn't work with the package https://github.com/pelx/angular100

pelx commented 3 years ago

as promised I have re-created the error:

https://github.com/pelx/angular100

cheers

laura

------ Original Message ------ From: "Yaroslav Admin" @.> To: "FortAwesome/angular-fontawesome" @.> Cc: "Laura" @.>; "Author" @.> Sent: Wednesday, 2 Jun, 21 At 19:56 Subject: Re: [FortAwesome/angular-fontawesome] Angular 11 installation failed (#306)

Of course. You are free to use whichever tool works best for you. I'm going to close this issue as everything works as intended in the new project and the issue is not actionable without a reproduction of the problem. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/FortAwesome/angular-fontawesome/issues/306#issuecomment-853306623 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7ORGS47TUVYGIY2DVP3LTTQZ5ENANCNFSM45ZGJTLQ .

devoto13 commented 3 years ago

Thank you for the reproduction @pelx!

As I've mentioned in https://github.com/FortAwesome/angular-fontawesome/issues/306#issuecomment-851301144, you should add FontAwesomeModule to the imports of the module where your component is declared to be able to use fa-icon component. That's not special for angular-fontawesome library, that's how Angular works, so we can't "fix" it in the library. You can read more about module encapsulation in this blog post for example.

Adding FontAwesomeModule to the imports + some cosmetic fixes makes the icon render in your application. You can find the fixed version at https://github.com/devoto13/angular100.

pelx commented 3 years ago

Yaroslavl,

thank you. I am not qualified to criticize. But I cant see how I can implement a dynamic icon binding in a component using this library.

cheers

Laura

------ Original Message ------ From: "Yaroslav Admin" @.> To: "FortAwesome/angular-fontawesome" @.> Cc: "Laura" @.>; "Mention" @.> Sent: Friday, 4 Jun, 21 At 17:39 Subject: Re: [FortAwesome/angular-fontawesome] Angular-fontawersome package issues with Angular 12. (#306)

Thank you for the reproduction @pelx https://github.com/pelx ! As I've mentioned in #306 (comment) https://github.com/FortAwesome/angular-fontawesome/issues/306#issuecomment-851301144 , you should add FontAwesomeModule to the imports of the module where your component is declared to be able to use fa-icon component. That's not special for angular-fontawesome library, that's how Angular works. You can read more about module encapsulation in this blog post https://indepth.dev/posts/1056/avoiding-common-confusions-with-modules-in-angular#module-encapsulation for example. Adding FontAwesomeModule to the imports + some cosmetic fixes makes the icon render in your application. You can find the fixed version at https://github.com/devoto13/angular100 https://github.com/devoto13/angular100 . — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/FortAwesome/angular-fontawesome/issues/306#issuecomment-854864114 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7ORGU37FBEOYIKCMCCWGTTRD6THANCNFSM45ZGJTLQ .

devoto13 commented 3 years ago

Do you mean something like https://github.com/FortAwesome/angular-fontawesome/issues/159#issuecomment-519527147?

pelx commented 3 years ago

no, I would like to have an icon as an @Input() in a component that can be used globally in an app.

------ Original Message ------ From: "Yaroslav Admin" @.> To: "FortAwesome/angular-fontawesome" @.> Cc: "Laura" @.>; "Mention" @.> Sent: Friday, 4 Jun, 21 At 22:51 Subject: Re: [FortAwesome/angular-fontawesome] Angular-fontawersome package issues with Angular 12. (#306)

Do you mean something like #159 (comment) https://github.com/FortAwesome/angular-fontawesome/issues/159#issuecomment-519527147 ? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/FortAwesome/angular-fontawesome/issues/306#issuecomment-855019842 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7ORGXUJI2WV3HOMKMX5Y3TRFDHVANCNFSM45ZGJTLQ .

devoto13 commented 3 years ago

You should be able to do so using exactly the same approach, just annotate the icon property with @Input() in your shared component.

jlorenzoC commented 3 years ago

Hi guys, hi @devoto13 , i just cloned: https://github.com/FortAwesome/angular-fontawesome, and next, is what my VSC integrated console shows:

https://user-images.githubusercontent.com/43883758/130127988-c6e7b1a6-9982-450c-ab5c-d9fd7d70eebd.mp4

picture:

image

next, is my Angular global setup:

image

next, the entire log in the integrated console, from the npm i to ng serve --port 4202:

Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\Proyectos\angular-fontawesome> npm i
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead.
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated

> @fortawesome/fontawesome-common-types@0.2.36 postinstall C:\Proyectos\angular-fontawesome\node_modules\@fortawesome\fontawesome-common-types
> node attribution.js

Font Awesome Free 0.2.36 by @fontawesome - https://fontawesome.com
License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)

> core-js@3.15.1 postinstall C:\Proyectos\angular-fontawesome\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
> https://opencollective.com/core-js 
> https://www.patreon.com/zloirock 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)

> core-js-pure@3.16.2 postinstall C:\Proyectos\angular-fontawesome\node_modules\core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"

Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!

The project needs your help! Please consider supporting of core-js:
> https://opencollective.com/core-js 
> https://patreon.com/zloirock 
> https://paypal.me/zloirock 
> bitcoin: bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz 

Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)

> esbuild@0.12.21 postinstall C:\Proyectos\angular-fontawesome\node_modules\esbuild
> node install.js

> @angular/cli@12.1.4 postinstall C:\Proyectos\angular-fontawesome\node_modules\@angular\cli
> node ./bin/postinstall/script.js

> @fortawesome/fontawesome-svg-core@1.2.36 postinstall C:\Proyectos\angular-fontawesome\node_modules\@fortawesome\fontawesome-svg-core
> node attribution.js

Font Awesome Free 1.2.36 by @fontawesome - https://fontawesome.com
License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)

> @fortawesome/free-regular-svg-icons@5.15.4 postinstall C:\Proyectos\angular-fontawesome\node_modules\@fortawesome\free-regular-svg-icons
> node attribution.js

Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com
License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)

> @fortawesome/free-solid-svg-icons@5.15.4 postinstall C:\Proyectos\angular-fontawesome\node_modules\@fortawesome\free-solid-svg-icons
> node attribution.js

Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com
License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\webpack-dev-server\node_modules\chokidar\node_monpm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN ajv-keywords@3.5.2 requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself. 

added 1611 packages from 1323 contributors and audited 1616 packages in 189.611s

131 packages are looking for funding
  run `npm fund` for details

found 1 moderate severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details
PS C:\Proyectos\angular-fontawesome> ng s --port 4202
Your global Angular CLI version (12.2.0) is greater than your local version (12.1.4). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
⠋ Generating browser application bundles (phase: setup)...Compiling @angular/core : es2015 as esm2015
Compiling @angular/common : es2015 as esm2015
Compiling @angular/platform-browser : es2015 as esm2015
Compiling @angular/platform-browser-dynamic : es2015 as esm2015
✔ Browser application bundle generation complete.

Initial Chunk Files   | Names         |      Size
vendor.js             | vendor        |   2.95 MB
polyfills.js          | polyfills     | 473.19 kB
styles.css, styles.js | styles        | 345.25 kB
main.js               | main          |  16.64 kB
runtime.js            | runtime       |   6.87 kB

                      | Initial Total |   3.77 MB

Build at: 2021-08-19T17:55:02.692Z - Hash: a8ed057d130d147cd6a2 - Time: 20147ms

./projects/demo/src/app/alternate-prefix.component.ts:3:0-60 - Error: Module not found: Error: Can't resolve '@fortawesome/angular-fontawesome' in 'C:\Proyectos\angular-fontawesome\projects\demo\src\app'

./projects/demo/src/app/app.module.ts:4:0-69 - Error: Module not found: Error: Can't resolve '@fortawesome/angular-fontawesome' in 'C:\Proyectos\angular-fontawesome\projects\demo\src\app'

Error: projects/demo/src/app/alternate-prefix.component.ts:2:41 - error TS2307: Cannot find module '@fortawesome/angular-fontawesome' or its corresponding type declarations.

2 import { FaConfig, FaIconLibrary } from '@fortawesome/angular-fontawesome';
                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Error: projects/demo/src/app/alternate-prefix.component.ts:11:15 - error NG2003: No suitable injection token for parameter 'faConfig' of class 'AlternatePrefixComponent'.
  Consider using the @Inject decorator to specify an injection token.

11   constructor(faConfig: FaConfig, library: FaIconLibrary) {
                 ~~~~~~~~

  projects/demo/src/app/alternate-prefix.component.ts:11:25
    11   constructor(faConfig: FaConfig, library: FaIconLibrary) {
                               ~~~~~~~~
    This type does not have a value, so it cannot be used as injection token.

Error: projects/demo/src/app/app.component.ts:2:41 - error TS2307: Cannot find module '@fortawesome/angular-fontawesome' or its corresponding type declarations.

2 import { FaConfig, FaIconLibrary } from '@fortawesome/angular-fontawesome';
                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Error: projects/demo/src/app/app.component.ts:53:15 - error NG2003: No suitable injection token for parameter 'library' of class 'AppComponent'.
  Consider using the @Inject decorator to specify an injection token.

53   constructor(library: FaIconLibrary, faConfig: FaConfig) {
                 ~~~~~~~

  projects/demo/src/app/app.component.ts:53:24
    53   constructor(library: FaIconLibrary, faConfig: FaConfig) {
                              ~~~~~~~~~~~~~
    This type does not have a value, so it cannot be used as injection token.

Error: projects/demo/src/app/app.module.ts:3:35 - error TS2307: Cannot find module '@fortawesome/angular-fontawesome' or its corresponding type declarations.

3 import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Error: projects/demo/src/app/app.module.ts:11:12 - error NG1010: Value at position 1 in the NgModule.imports of AppModule is not a reference
  Value could not be determined statically.

11   imports: [BrowserModule, FontAwesomeModule],
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  projects/demo/src/app/app.module.ts:11:28
    11   imports: [BrowserModule, FontAwesomeModule],
                                  ~~~~~~~~~~~~~~~~~
    Unknown reference.

Error: projects/demo/src/app/testing/explicit-reference.component.ts:6:14 - error NG8001: 'fa-icon' is not a known element:   
1. If 'fa-icon' is an Angular component, then verify that it is part of this module.
2. If 'fa-icon' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress 
this message.

6   template: '<fa-icon [icon]="faUser"></fa-icon>',
               ~~~~~~~~~~~~~~~~~~~~~~~~~

Error: projects/demo/src/app/testing/explicit-reference.component.ts:6:23 - error NG8002: Can't bind to 'icon' since it isn't 
a known property of 'fa-icon'.
1. If 'fa-icon' is an Angular component and it has 'icon' input, then verify that it is part of this module.
2. If 'fa-icon' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress 
this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.

6   template: '<fa-icon [icon]="faUser"></fa-icon>',
                        ~~~~~~~~~~~~~~~

Error: projects/demo/src/app/testing/icon-library.component.ts:5:14 - error NG8001: 'fa-icon' is not a known element:
1. If 'fa-icon' is an Angular component, then verify that it is part of this module.
2. If 'fa-icon' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress 
this message.

5   template: '<fa-icon icon="user"></fa-icon>',
               ~~~~~~~~~~~~~~~~~~~~~

** Angular Live Development Server is listening on localhost:4202, open your browser on http://localhost:4202/ **

✔ Browser application bundle generation complete.

5 unchanged chunks

Build at: 2021-08-19T17:55:03.832Z - Hash: a8ed057d130d147cd6a2 - Time: 593ms

./projects/demo/src/app/alternate-prefix.component.ts:3:0-60 - Error: Module not found: Error: Can't resolve '@fortawesome/angular-fontawesome' in 'C:\Proyectos\angular-fontawesome\projects\demo\src\app'

./projects/demo/src/app/app.module.ts:4:0-69 - Error: Module not found: Error: Can't resolve '@fortawesome/angular-fontawesome' in 'C:\Proyectos\angular-fontawesome\projects\demo\src\app'

Error: projects/demo/src/app/alternate-prefix.component.ts:2:41 - error TS2307: Cannot find module '@fortawesome/angular-fontawesome' or its corresponding type declarations.

2 import { FaConfig, FaIconLibrary } from '@fortawesome/angular-fontawesome';
                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Error: projects/demo/src/app/alternate-prefix.component.ts:11:15 - error NG2003: No suitable injection token for parameter 'faConfig' of class 'AlternatePrefixComponent'.
  Consider using the @Inject decorator to specify an injection token.

11   constructor(faConfig: FaConfig, library: FaIconLibrary) {
                 ~~~~~~~~

  projects/demo/src/app/alternate-prefix.component.ts:11:25
    11   constructor(faConfig: FaConfig, library: FaIconLibrary) {
                               ~~~~~~~~
    This type does not have a value, so it cannot be used as injection token.

Error: projects/demo/src/app/app.component.ts:2:41 - error TS2307: Cannot find module '@fortawesome/angular-fontawesome' or its corresponding type declarations.

2 import { FaConfig, FaIconLibrary } from '@fortawesome/angular-fontawesome';
                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Error: projects/demo/src/app/app.component.ts:53:15 - error NG2003: No suitable injection token for parameter 'library' of class 'AppComponent'.
  Consider using the @Inject decorator to specify an injection token.

53   constructor(library: FaIconLibrary, faConfig: FaConfig) {
                 ~~~~~~~

  projects/demo/src/app/app.component.ts:53:24
    53   constructor(library: FaIconLibrary, faConfig: FaConfig) {
                              ~~~~~~~~~~~~~
    This type does not have a value, so it cannot be used as injection token.

Error: projects/demo/src/app/app.module.ts:3:35 - error TS2307: Cannot find module '@fortawesome/angular-fontawesome' or its corresponding type declarations.

3 import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Error: projects/demo/src/app/app.module.ts:11:12 - error NG1010: Value at position 1 in the NgModule.imports of AppModule is not a reference
  Value could not be determined statically.

11   imports: [BrowserModule, FontAwesomeModule],
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  projects/demo/src/app/app.module.ts:11:28
    11   imports: [BrowserModule, FontAwesomeModule],
                                  ~~~~~~~~~~~~~~~~~
    Unknown reference.

Error: projects/demo/src/app/testing/explicit-reference.component.ts:6:14 - error NG8001: 'fa-icon' is not a known element:   
1. If 'fa-icon' is an Angular component, then verify that it is part of this module.
2. If 'fa-icon' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress 
this message.

6   template: '<fa-icon [icon]="faUser"></fa-icon>',
               ~~~~~~~~~~~~~~~~~~~~~~~~~

Error: projects/demo/src/app/testing/explicit-reference.component.ts:6:23 - error NG8002: Can't bind to 'icon' since it isn't 
a known property of 'fa-icon'.
1. If 'fa-icon' is an Angular component and it has 'icon' input, then verify that it is part of this module.
2. If 'fa-icon' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress 
this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.

6   template: '<fa-icon [icon]="faUser"></fa-icon>',
                        ~~~~~~~~~~~~~~~

Error: projects/demo/src/app/testing/icon-library.component.ts:5:14 - error NG8001: 'fa-icon' is not a known element:
1. If 'fa-icon' is an Angular component, then verify that it is part of this module.
2. If 'fa-icon' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress 
this message.

5   template: '<fa-icon icon="user"></fa-icon>',
               ~~~~~~~~~~~~~~~~~~~~~
devoto13 commented 3 years ago

@jlorenzoC I think what you are missing is to build the angular-fontawesome library before you attempt to run the demo application. Please refer to the developer documentation for information on how to develop the library.

jlorenzoC commented 3 years ago

@jlorenzoC I think what you are missing is to build the angular-fontawesome library before you attempt to run the demo application. Please refer to the developer documentation for information on how to develop the library.

yeah! that was it! just ran npm run build and then ng s --port 4202 and the demo app is runing ok!! thanks