react-pdf
react-pdf copied to clipboard
Webpack version inconsistency after `npm update`
Before you start - checklist
- [X] I followed instructions in documentation written for my React-PDF version
- [X] I have checked if this bug is not already reported
- [X] 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
Whenever I run an npm update
command to update other packages and after that I try an npm run start
or npm run build
I get following error message:
The only way I currently found to fix this is to manually remove the node_modules
folder and delete the package-lock.json
file, uninstall react-pdf
, run a clean npm install
and only afterwards run once more npm i react-pdf
. How can I fix this?
Steps to reproduce
- Install latest version
- Downgrade another package
- Run
npm update
- Run
npm run start
ornpm run build
Expected behavior
Should not have webpack inconsistency
Actual behavior
Additional information
No response
Environment
- **Browser (if applicable)**: Version 98.0.4758.9 (Official Build) dev (arm64)
- **React-PDF version**: 5.6.0
- **React version**: 17.0.1
- **Webpack version (if applicable)**:
No idea what your npm is doing, but react-pdf
does not depend on webpack
. It does, however, depend on file-loader
, so you might be a victim of idiotic npm 7 behavior where peerDependencies are automatically installed.
Ok thanks for the info. Would you perhaps have an idea into which direction to point me to solve my issue perhaps? Many thanks
file-loader
should be a devDependency in project.json instead an dependency. This causes problems with create-react-app
>= 5.0.0 too.
file-loader
is not really a devDependency
. It has to install with React-PDF for Webpack 4 entry file to work. However, it has no use in Webpack 5 entry file, Parcel entry file, generic entry file... Perhaps dropping support for Webpack 4 altogether would be a better choice.
file-loader
is not really adevDependency
. It has to install with React-PDF for Webpack 4 entry file to work. However, it has no use in Webpack 5 entry file, Parcel entry file, generic entry file... Perhaps dropping support for Webpack 4 altogether would be a better choice.
Hmm right, but this would make it a perfect peerDependency, only required in combination with webpack 4.
Agreed! Let's do this.
Note that peerDependencies are now installed by default in npm7+, so probably we also should mark the dependency as optional: https://docs.npmjs.com/cli/v8/configuring-npm/package-json#peerdependenciesmeta
Would love to see this fixed!
@wojtekmaj I've added the otional flag to the PR
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.
Any change to get a release?
Ahh I see it is in v6.0.0-beta.3, thanks.
I'm using webpack 5 with react-pdf 6.1.1 but the build breaks because I don't have file-loader installed. For all other assets I use the new asset loader from webpack. Is it still required for webpack 5 to install file-loader when using react-pdf or it this a bug ?
Have you tried this from the docs?
Otherwise "build breaks" is insufficient to help
Ah i see I was using entry.webpack
instead of entry.webpack5
. Thanks all working now :)
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.
This issue was closed because it has been stalled for 14 days with no activity.