Skip to content

Bug: Cannot find module or its corresponding type declarations when importing font awesome pro icons #558

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DevLaka opened this issue Mar 21, 2024 · 3 comments

Comments

@DevLaka
Copy link

DevLaka commented Mar 21, 2024

Bug description

I'm currently working on a React TypeScript project where I initially used Font Awesome free icons. However, I've realized the need to improve the aesthetics by incorporating Font Awesome Pro icons. Transitioning to Font Awesome Pro might not be as straightforward as I initially thought.

I've set up Font Awesome Pro following the documentation provided here:
Font Awesome Docs

Here are the steps I followed:

  1. Created a Kit Package:
Icons: pro
Technology: SVG
Subset: Auto-subsetting
Styles: All styles
Features: Enable NPM download and Enable compatibility with older versions
  1. Created a .npmrc file in the folder where package.json exists. .nmprc File Contents:
@awesome.me:registry=https://npm.fontawesome.com/
//npm.fontawesome.com/:_authToken=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

  1. Installed below packages.
npm install --save @awesome.me/kit-KIT_CODE@latest
npm i --save @fortawesome/fontawesome-svg-core
npm i --save @awesome.me/kit-KIT_CODE
npm i --save @fortawesome/react-fontawesome@latest
  1. Attempted to import icons to a React component using the following code:
import { faHouse } from '@awesome.me/kit-KIT_CODE/icons/classic/solid'

However, I'm encountering an error stating: "Module '@awesome.me/kit-code/icons/classic/solid/' or its corresponding type declarations cannot be found.

Also, I noticed that the index.d.ts file in the @awesome.me node module exports an empty object.

Font Awesome version

v6

Serving

Kit

Implementation

SVG+JS

Browser and Operating System

  • Chrome version 122 on Windows 10
@DevLaka
Copy link
Author

DevLaka commented Mar 21, 2024

Add "moduleResoluction": "bundler" within the compilerOptions object in the tsconfig.json file like below.

    {
      "compilerOptions": {
        "moduleResolution": "bundler"
      },
    }

It's disappointing that this isn't mentioned in any Font Awesome documentation.

@DevLaka DevLaka closed this as completed Mar 21, 2024
@robmadole
Copy link
Member

We'll get it added. Thanks for letting us know how you solved it.

@jamesarosen
Copy link

jamesarosen commented Jun 25, 2024

https://docs.fontawesome.com/web/use-with/react/use-with#typescript would be a great place for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants