Webpack error when attemping to use custom build
Description
I'm just adding exifreader to a personal project. I'm testing doing a custom build to see if it improves the speed of reading data (feel free to tell me it doesn't!).
I've added the below to my package.json:
"exifreader": {
"include": {
"jpg": true,
"png": true,
"tiff": true,
"heic": true,
"webp": true,
"gif": true,
"file": true,
"png_file": true,
"exif": [
"Model",
"Lens",
"LensModel",
"ExposureTime",
"FNumber",
"FocalLengthIn35mmFilm",
"ISOSpeedRatings",
"DateTimeOriginal",
"CreateDate",
"ModifyDate",
"By-line",
"Copyright Notice",
"Rating",
"GPSDateStamp",
"GPSTimeStamp",
"GPSAltitude",
"Image Width",
"ImageWidth",
"Image Height",
"ImageHeight"
]
}
},
When I run npm install exifreader I get the following error:
npm ERR! command failed
npm ERR! command sh -c node bin/build.js --only-with-config
npm ERR! CLI for webpack must be installed.
npm ERR! webpack-cli (https://github.com/webpack/webpack-cli)
npm ERR!
npm ERR! We will use "npm" to install the CLI via "npm install -D webpack-cli".
npm ERR! Do you want to install 'webpack-cli' (yes/no): node:child_process:960
npm ERR! throw err;
npm ERR! ^
npm ERR!
npm ERR! Error: Command failed: npx [email protected]
I've also tried installing the webpack-cli as per the error and that had no effect.
Additional details
- ExifReader version: latest
- Web browser and version:
- Node version: 20
What I expected would happen:
Expect npm install to succeed. It works fine if I remove the custom stuff from my package.json.
What really happened:
NPM install fails.
Hi! I will try to reproduce this. Do you happen to have webpack installed globally on your system? When looking around it sounded like that could be one reason for the error.
Oh, and a custom build should improve speed a little but it's probably only going to show for images that have a lot of the other types of metadata that it would skip with the custom build (XMP, ICC, etc.).
I don't believe I have webpack. But as noted, I did try adding it as a project dependancy and that didn't seem to help.
RE speed: I was previously using exif-parser which was quite a bit faster. But it's not a big problem - I was previously running on each build, but am now going to be pre-rendering data and saving it to file.
Sorry for not prioritizing this sooner. It has been hard to reproduce. Still couldn't do it but if you are still interested in a solution to this I have a PR that at least should not complain about a missing webpack-cli: #380
All my tests pass and it should be more robust in general so I will probably merge it either way.
Released as 4.23.4. Please re-open this issue if you're still having problems.
Thanks for looking at this @mattiasw! I've not worked on my site for a bit now, but when I next get back to it I'll update this.