mikecousins/react-pdf-js

Error when installing version 6.1.1

Closed this issue · 11 comments

I have an error when installing version 6.1.1 :
An unexpected error occurred: "true is not iterable!".

I use version 2.16.105 of pdfjs-dist

Hey jimbiscuit, I faced the same issue! Did you manage to resolve it with version 6.1.1?

I'm facing a similar error. Specifically, when installing @mikecousins/react-pdf version 6 through yarn.

This is the error I see in yarn:

error An unexpected error occurred: "_iterator3[Symbol.iterator] is not a function".

These yarn installations fail when installing:

yarn add @mikecousins/react-pdf@6.1.1
yarn add @mikecousins/react-pdf@6.1.0
yarn add @mikecousins/react-pdf@6.0.0-alpha.1

These yarn and npm installations succeed when installing:

yarn add @mikecousins/react-pdf@5.5.1
npm install @mikecousins/react-pdf@6.1.1
npm install @mikecousins/react-pdf@6.1.0
npm install @mikecousins/react-pdf@5.5.1

Here is info from the yarn-error.log:

Yarn version: 
  1.22.19

Node version: 
  16.17.0

Trace: 
  TypeError: _iterator3[Symbol.iterator] is not a function
      at /Users/developer/.yarn/releases/yarn-1.22.19.cjs:49042:168
      at Generator.next (<anonymous>)
      at step (/Users/developer/.yarn/releases/yarn-1.22.19.cjs:310:30)
      at /Users/developer/.yarn/releases/yarn-1.22.19.cjs:328:14
      at new Promise (<anonymous>)
      at new F (/Users/developer/.yarn/releases/yarn-1.22.19.cjs:25830:28)
      at /Users/developer/.yarn/releases/yarn-1.22.19.cjs:307:12
      at PackageLinker.linkBinDependencies (/Users/developer/.yarn/releases/yarn-1.22.19.cjs:49104:7)
      at /Users/developer/.yarn/releases/yarn-1.22.19.cjs:49638:28
      at Generator.next (<anonymous>)

I forget to mention that I use yarn
@peironggg I have the problem with 6.1.1 and 6.1.0

@jimbiscuit I just ran up against the same issue. Did you ever find a resolution to the problem?

@cayman1066 not yet, the pdf viewer integration in my project is currently pending for the moment

This is happening because yarn only supports array syntax for bundleDependencies but which is set to true here

You can switch to npm for a quick fix

Not an issue with react-pdf@5.5.1

same issue here installing with yarn, solved by downgrading to 5.5.1

To solve this at the package level, I think you could change replace bundleDependencies: true with:

bundleDependencies: [
    "pdfjs-dist",
    "react",
    "react-dom"
]

Not sure if it matters that these are peerDependencies.

update: actually, downgrading to 5.5.1 allows the package to install, but then throws as error at build time to the effect of "cannot use require() switch to a dynamic import." So, from what I can tell, it's simply not possible currently to use this package with yarn. to solve for this, I simply copied the main application logic into my codebase.

I'm hoping this is fixed now. I did a bunch of work updating to latest and linting the package types: https://publint.dev/@mikecousins/react-pdf. Let me know if it's still not playing well with people's setups but it should work properly now in CommonJS or ESM setups.