I have a React app built with craco that I want to add react-pdf to display PDF files in a react component.
I'm getting the following error:
I've added the following to the craco.config.js file which apparently replaces the webpack.config
module.exports = {
plugins: [
{
plugin: CracoLessPlugin,
options: {
lessLoaderOptions: {
lessOptions: {
modifyVars: { '@primary-color': '#1c48f2' },
modules: true,
javascriptEnabled: true
}
},
}
},
{ plugin: CracoTerserOverridePlugin }
],
webpack: {
options: {
presets: [
"@babel/preset-env",
"@babel/preset-react"
],
plugins: [
[
"@babel/plugin-proposal-class-properties",
"@babel/plugin-syntax-class-properties"
]
],
},
plugins: process.env.NODE_ENV === 'production' ? [
...
}),
] : [],
}
};
tsconfig.json
{
"compilerOptions": {
"baseUrl": "src",
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
}
I've tried positions within this object, but nothing seems to fix it. I'm assuming I need to add something else.

tsconfig.jsonfile?node_modulesto theexcludeproperty in yourtsconfig.json.