You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I followed instructions in documentation written for my React-PDF version
I have checked if this bug is not already reported
I have checked if an issue is not listed in Known issues
If I have a problem with PDF rendering, I checked if my PDF renders properly in PDF.js demo
Description
I build my project(webpack 5) get an error when using react-pdf of v5.7.2.
Module not found: Error: Can't resolve 'canvas' in 'C:\Users\Zeffon\Desktop\app\english\node_modules\.pnpm\pdfjs-dist@2.9.359\node_modules\pdfjs-dist\legacy\build'
But It can run normally and It's just an error when build. I tired to use different verision, but it failed. I tired to install react-pdf of came version pdfjs-dist. But it failed too. So I am wondering if it's because I use 'pnpm'.
And what should i do?
Steps to reproduce
install deps
"react-pdf": "^5.7.2"
"pdfjs-dist": "^2.12.313",
config
import path from 'path'
import CopyWebpackPlugin from 'copy-webpack-plugin'
// eslint-disable-next-line no-restricted-globals
const cMapsDir = path.join(path.dirname(require.resolve('pdfjs-dist/package.json')), 'cmaps')
module.exports = function (context, options) {
return {
name: 'custom-docusaurus-plugin',
configureWebpack() {
return {
plugins: [
new CopyWebpackPlugin({
patterns: [{ from: cMapsDir, to: 'cmaps/' }]
})
]
}
}
}
}
use
import { Document, Page, pdfjs } from 'react-pdf/dist/esm/entry.webpack5'
import pdfjsWorker from 'pdfjs-dist/build/pdf.worker.entry'
pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker
Before you start - checklist
Description
I build my project(webpack 5) get an error when using react-pdf of v5.7.2.
But It can run normally and It's just an error when build. I tired to use different verision, but it failed. I tired to install react-pdf of came version pdfjs-dist. But it failed too. So I am wondering if it's because I use 'pnpm'.
And what should i do?
Steps to reproduce
Expected behavior
build success
Actual behavior
build fail
Additional information
No response
Environment
The text was updated successfully, but these errors were encountered: