Closed vuthanhtung172906 closed 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' `
`
I have same issue
solved in this way
installed latest version
webpack version
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
@Andreamoon can confirm that adding fs: false
in resolve.fallback fixes the problem
Also if someone (like me) will have issue with react/jsx-runtime
, just add 'react/jsx-runtime': 'react/jsx-runtime.js'
inside resolve.fallback
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)
This issue is also related.
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
Bellow solution worked for me.
npm i @craco/craco or yarn add @craco/craco
Create craco.config.js in the root of your project.
Bellow code in craco.config.js module.exports = { webpack: { configure: (webpackConfig, { env, paths }) => { webpackConfig.resolve.fallback = { fs: false, os: false, path: false, }; return webpackConfig; }, }, };
modify your package.json "build": "craco build", "start": "craco start", "test": "craco test",
yarn install or npm update
Bellow solution worked for me.
- npm i @craco/craco or yarn add @craco/craco
- Create craco.config.js in the root of your project.
- Bellow code in craco.config.js module.exports = { webpack: { configure: (webpackConfig, { env, paths }) => { webpackConfig.resolve.fallback = { fs: false, os: false, path: false, }; return webpackConfig; }, }, };
- modify your package.json "build": "craco build", "start": "craco start", "test": "craco test",
- yarn install or npm update
Thanks a lot, It's work on me
Bellow solution worked for me.
- npm i @craco/craco or yarn add @craco/craco
- Create craco.config.js in the root of your project.
- Bellow code in craco.config.js module.exports = { webpack: { configure: (webpackConfig, { env, paths }) => { webpackConfig.resolve.fallback = { fs: false, os: false, path: false, }; return webpackConfig; }, }, };
- modify your package.json "build": "craco build", "start": "craco start", "test": "craco test",
- yarn install or npm update
this worked!!! I am so relieved right now
Will try to resolve this soon. Didn't realize
jpeg-exif
depended onfs
. 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'" ?
Please we need this fix asap, I dont prefer to go for another solution/component
Will try to fix it soon but can't give a estimated time, given development here comes from my free time
you can find a potential workaround here: https://github.com/diegomura/react-pdf/issues/2535#issuecomment-1906139993
I am having the same issue. Has anyone found a workaround using NPM?
Please fix it ASAP!
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"
},
for pnpm users
"dependencies": {
"@react-pdf/renderer": "^3.3.3",
},
"pnpm": {
"overrides": {
"@react-pdf/image": "2.2.3",
"@react-pdf/pdfkit": "3.0.4"
}
},
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
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"
},
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???
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'
Bellow solution worked for me.
- npm i @craco/craco or yarn add @craco/craco
- Create craco.config.js in the root of your project.
- Bellow code in craco.config.js module.exports = { webpack: { configure: (webpackConfig, { env, paths }) => { webpackConfig.resolve.fallback = { fs: false, os: false, path: false, }; return webpackConfig; }, }, };
- modify your package.json "build": "craco build", "start": "craco start", "test": "craco test",
- yarn install or npm update
thanks bro, its worked!
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.
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 !
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! 😅
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