Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: Can't resolve 'iconv-lite' #1712

Closed
acomanescu opened this issue Feb 9, 2022 · 12 comments · Fixed by #1908
Closed

Warning: Can't resolve 'iconv-lite' #1712

acomanescu opened this issue Feb 9, 2022 · 12 comments · Fixed by #1908

Comments

@acomanescu
Copy link

Describe the bug
Using the latest version "@react-pdf/renderer": "^2.1.1" with Next.js I get the following warning:

./node_modules/@react-pdf/fontkit/lib/fontkit.browser.es.js
Module not found: Can't resolve 'iconv-lite' in './node_modules/@react-pdf/fontkit/lib'

Import trace for requested module:
./node_modules/@react-pdf/font/lib/index.browser.js
./node_modules/@react-pdf/renderer/lib/react-pdf.browser.es.js

Desktop:

  • OS: MacOS
  • Browser: Any
  • React-pdf version: 2.1.1
@jonahallibone
Copy link

Same issue here, same environment

@IsaacTrevino
Copy link

IsaacTrevino commented Feb 18, 2022

Experiencing the same, with NextJS.
using "@react-pdf/renderer": "^1.6.17" for the meantime

@Kiko915
Copy link

Kiko915 commented Mar 3, 2022

It also occured to me when using with NextJS.

@n-hiraha
Copy link

n-hiraha commented Mar 3, 2022

Exactly the same problem

@LB22
Copy link

LB22 commented Mar 10, 2022

Same here.

"@react-pdf/renderer": "^2.1.1",
"next": "^12.0.10",
"react": "17.0.2",

wait - compiling...
warn - ./node_modules/@react-pdf/fontkit/lib/fontkit.browser.es.js
Module not found: Can't resolve 'iconv-lite' in 'C:\WebAppDir\node_modules@react-pdf\fontkit\lib'

./node_modules/restructure/src/DecodeStream.js
Module not found: Can't resolve 'iconv-lite' in 'C:\WebAppDir\node_modules\restructure\src'

./node_modules/restructure/src/EncodeStream.js
Module not found: Can't resolve 'iconv-lite' in 'C:\WebAppDir\node_modules\restructure\src'

@marcog83
Copy link

marcog83 commented Mar 24, 2022

hi, i faced the same problem and looking at the webpack configuration, i solved the error setting an alias for iconv-lite to false like here

config.resolve = {
        alias: {
          // TODO: ignore iconv-lite on default because it contains exotic encodings like `win1251`, that isn't used in pdf
          'iconv-lite': false,
        },
        fallback: {
          process: require.resolve('process/browser'),
          zlib: require.resolve('browserify-zlib'),
          stream: require.resolve('stream-browserify'),
          util: require.resolve('util'),
          buffer: require.resolve('buffer'),
          asset: require.resolve('assert'),
        },
      };

LINK

@isaaclyman
Copy link

npm install --save iconv-lite fixed it for me, of course, but it's odd that it's not an explicit dependency of the library.

@yanayhollander
Copy link

as @isaaclyman suggested yarn add --dev iconv-lite fix it for me

@jonahallibone
Copy link

@diegomura I still get this issue in 2.3.0

@diegomura
Copy link
Owner

This change is not yet published. Will be included in 3.0.0 when we publish it

@Killal19
Copy link

I tried them but I still face the same issue with React.js

@Silvia-t
Copy link

Same issue two years after the last comment -- this fixed it

npm install --save iconv-lite fixed it for me, of course, but it's odd that it's not an explicit dependency of the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.