[Fix] Attempted import error: ‘create’ is not exported from ‘fontkit’

The Error “Attempted import error: ‘create’ is not exported from ‘fontkit’ “, is an error that is invoked when you are working on react and are trying to use the react-pdf/renderer package which includes functionality to improve pdf downloads.

Given below is the snippet of the error you might get:

Attempted import error: 'create' is not exported from 'fontkit' 

The error, “Attempted import error: ‘create’ is not exported from ‘fontkit’ ” is seen because of incorrect version numbers mentioned in package.json dependencies. Specific version numbers are necessary for the pdf functionality to work in your system.

To fix the error, “Attempted import error: ‘create’ is not exported from ‘fontkit'”, add proper codes to package.json dependencies using command @react-pdf/rendered”:” 2.1.0″ and @react-pdf/font”: “2.2.0 and error would be fixed.

You will also have to add a resolutions objects with the correct version number using command @react-pdf/font”: “2.2.0 and error Attempted import error: ‘create’ is not exported from ‘fontkit’ would be fixed.

To fix the error “Attempted import error: ‘create’ is not exported from ‘fontkit’ “, you will have to follow the steps mentioned below:

First you will have to add some of the following codes in your package.json dependencies. The codes which will have to added is given below:

"@react-pdf/rendered":" 2.1.0",
"@react-pdf/font": "2.2.0",

You will also have to add a resolutions objects with the correct version number. The code to do so is given below:

"resolutions": {
    "@react-pdf/font": "2.2.0"
  },

You only need to add this version to an existing resolutions object. You’ll see that the version number lacks a^.

Next you will have to remove yarn.lock or restart yarn/npm install after running lock or package-lock.json.

This should help you fix the error, “Attempted import error: ‘create’ is not exported from ‘fontkit’ “.

Conclusion

To fix the error, “Attempted import error: ‘create’ is not exported from ‘fontkit’ ” you will have to add some codes to your package.json dependencies.

You will also have to add a resolutions objects with the correct version number.