diegomura / react-pdf

📄 Create PDF files using React
https://react-pdf.org
MIT License
14.92k stars 1.18k forks source link

Not found jpeg-exif #2541

Closed vuthanhtung172906 closed 9 months ago

vuthanhtung172906 commented 9 months ago

I have a error when use react-pdf, In old version i use 3.1.14 it's still working good after you have update new version. This error when i delete node-modules and try to install again all dependency in project ERROR in ./node_modules/jpeg-exif/lib/index.js 3:10-23

This error appear in both version 3.1.14 and version 3.3.2

Andreamoon commented 9 months ago

same issue for me using "@react-pdf/renderer": "^3.1.9"

Module not found: Error: Can't resolve 'fs' in './node_modules/jpeg-exif/lib' `

nodejs ==> v20.10.0

npm == >10.2.3

`

wr9dg17 commented 9 months ago

I have same issue

nodejs: v16.17

npm: 8.15

Andreamoon commented 9 months ago

solved in this way

installed latest version

"@react-pdf/renderer": "^3.3.2"

webpack version

"webpack": "^5.64.2",

on my webpack.confing.js

rules:[{ test: /\.[jt]sx?$/, exclude: /(node_modules)(yoga-layout)/, use: { loader: "swc-loader", options: { parseMap: true, }, }, }, ]

resolve:{ fallback: { fs: false, },}

before I excluded node_modules chage to ==> exclude: /(node_modules)(yoga-layout)/, for my rules on webpack 5 conf

wr9dg17 commented 9 months ago

@Andreamoon can confirm that adding fs: false in resolve.fallback fixes the problem

"@react-pdf/renderer": "^3.1.14"

"webpack": "^5.89.0"

Also if someone (like me) will have issue with react/jsx-runtime, just add 'react/jsx-runtime': 'react/jsx-runtime.js' inside resolve.fallback

diegomura commented 9 months ago

Will try to resolve this soon. Didn't realize jpeg-exif depended on fs. Being this a third party lib I'll need to submit a PR to it, or fork it and fix it. But want to avoid the latter as it would be great to use actual third-party deps instead of forks (trying to remove @react-pdf/pdfkit soon)

acomanescu commented 9 months ago

This issue is also related.

vuthanhtung172906 commented 9 months ago
Screenshot 2024-01-23 at 10 28 57

This is my code in webpack.config.ts. But maybe it's not working b.c issue relate to NotFound Jpeg still not resovled

Maybe i didn't override webpack config in my create-react-app

ridoywsit commented 9 months ago

Bellow solution worked for me.

  1. npm i @craco/craco or yarn add @craco/craco

  2. Create craco.config.js in the root of your project.

  3. Bellow code in craco.config.js module.exports = { webpack: { configure: (webpackConfig, { env, paths }) => { webpackConfig.resolve.fallback = { fs: false, os: false, path: false, }; return webpackConfig; }, }, };

  4. modify your package.json "build": "craco build", "start": "craco start", "test": "craco test",

  5. yarn install or npm update

vuthanhtung172906 commented 9 months ago

Bellow solution worked for me.

  1. npm i @craco/craco or yarn add @craco/craco
  2. Create craco.config.js in the root of your project.
  3. Bellow code in craco.config.js module.exports = { webpack: { configure: (webpackConfig, { env, paths }) => { webpackConfig.resolve.fallback = { fs: false, os: false, path: false, }; return webpackConfig; }, }, };
  4. modify your package.json "build": "craco build", "start": "craco start", "test": "craco test",
  5. yarn install or npm update

Thanks a lot, It's work on me

Oxygene1 commented 9 months ago

Bellow solution worked for me.

  1. npm i @craco/craco or yarn add @craco/craco
  2. Create craco.config.js in the root of your project.
  3. Bellow code in craco.config.js module.exports = { webpack: { configure: (webpackConfig, { env, paths }) => { webpackConfig.resolve.fallback = { fs: false, os: false, path: false, }; return webpackConfig; }, }, };
  4. modify your package.json "build": "craco build", "start": "craco start", "test": "craco test",
  5. yarn install or npm update

this worked!!! I am so relieved right now

janandabhishek commented 9 months ago

Will try to resolve this soon. Didn't realize jpeg-exif depended on fs. Being this a third party lib I'll need to submit a PR to it, or fork it and fix it. But want to avoid the latter as it would be great to use actual third-party deps instead of forks (trying to remove @react-pdf/pdfkit soon)

Is there any estimated time for the fix: "Error: Can't resolve 'fs' in './node_modules/jpeg-exif/lib'" ?

EasyGo-Digital commented 9 months ago

Please we need this fix asap, I dont prefer to go for another solution/component

diegomura commented 9 months ago

Will try to fix it soon but can't give a estimated time, given development here comes from my free time

farce1 commented 9 months ago

you can find a potential workaround here: https://github.com/diegomura/react-pdf/issues/2535#issuecomment-1906139993

ericdelich13 commented 9 months ago

I am having the same issue. Has anyone found a workaround using NPM?

UzairAsadBaig commented 9 months ago

Please fix it ASAP!

ytreister commented 9 months ago

I finally found a fix that worked for me with plain npm: Modified my package.json:

    "dependencies": {
        "@react-pdf/renderer": "3.3.4",
        "@react-pdf/layout": "3.6.2"
    },
    "overrides": {
        "@react-pdf/image": "2.2.3",
        "@react-pdf/pdfkit": "3.0.4"
    },
EasyGo-Digital commented 9 months ago

for pnpm users

"dependencies": {
        "@react-pdf/renderer": "^3.3.3",
    },
    "pnpm": {
        "overrides": {
            "@react-pdf/image": "2.2.3",
            "@react-pdf/pdfkit": "3.0.4"
        }
    },
Oxygene1 commented 9 months ago

guys, this worked like maagic>> yarn add @craco/craco or npm install @craco/craco >> create a craco.config.js file in your root folder >>

add this to your craco config >>

module.exports = { webpack: { configure: (webpackConfig, { env, paths }) => { webpackConfig.resolve.fallback = { fs: false, os: false, path: false, }; return webpackConfig; }, }, };

once that is added,

modify your package.json file while you let craco handle your scripts

"scripts":{ "build": "craco build", "start": "craco start", "test": "craco test", }

"browser": { "fs": false, "os": false, "path": false }

that's all you need

ericdelich13 commented 9 months ago

for anyone using npm the below worked fine. However, the one problem I had is I was running npm version 6.x.x and apparently unless you are running at least 8.3.x the dependency section is not built correctly or at all. I had to update my npm and node version for this to work.

"dependencies": {
    "@react-pdf/renderer": "3.3.3"
},
"overrides": {
    "@react-pdf/image": "2.2.3",
    "@react-pdf/pdfkit": "3.0.4"
},
Ali-muhammed7040 commented 9 months ago

solved in this way

installed latest version

"@react-pdf/renderer": "^3.3.2"

webpack version

"webpack": "^5.64.2",

on my webpack.confing.js

rules:[{ test: /\.[jt]sx?$/, exclude: /(node_modules)(yoga-layout)/, use: { loader: "swc-loader", options: { parseMap: true, }, }, }, ]

resolve:{ fallback: { fs: false, },}

before I excluded node_modules chage to ==> exclude: /(node_modules)(yoga-layout)/, for my rules on webpack 5 conf

Can you please share your webpack.config.js???

Owais-Ahmed7 commented 9 months ago

Am using yarn no webpack and its giving this issue still not solved in latest versions

ERROR in ./node_modules/jpeg-exif/lib/index.js 3:10-23 Module not found: Error: Can't resolve 'fs' in '/Users/owais/Developer/software/client/node_modules/jpeg-exif/lib'

aangindra commented 9 months ago

Bellow solution worked for me.

  1. npm i @craco/craco or yarn add @craco/craco
  2. Create craco.config.js in the root of your project.
  3. Bellow code in craco.config.js module.exports = { webpack: { configure: (webpackConfig, { env, paths }) => { webpackConfig.resolve.fallback = { fs: false, os: false, path: false, }; return webpackConfig; }, }, };
  4. modify your package.json "build": "craco build", "start": "craco start", "test": "craco test",
  5. yarn install or npm update

thanks bro, its worked!

carlosgomez-theta commented 9 months ago

Hello, any solution without the proposed solutions. In our particular case we cannot go with any solution proposed above. We want to continue using this amazing library. We really need your fixes.

jespadas commented 9 months ago

for anyone using npm the below worked fine. However, the one problem I had is I was running npm version 6.x.x and apparently unless you are running at least 8.3.x the dependency section is not built correctly or at all. I had to update my npm and node version for this to work.

"dependencies": {
  "@react-pdf/renderer": "3.3.3"
},
"overrides": {
  "@react-pdf/image": "2.2.3",
  "@react-pdf/pdfkit": "3.0.4"
},

This worked for me !! Thanks a lot !

ThomasRedstone commented 9 months ago

Interestingly it was this that worked for me:

  "overrides": {
    "@react-pdf/renderer": "3.1.13",
    "@react-pdf/image": "2.2.3",
    "@react-pdf/pdfkit": "3.0.4",
    "@react-pdf/layout": "3.5.0"
  },

I do wonder if some other combination would have done the job, but I've had enough delays generating my CV already, and now it works I'm not touching it! 😅