Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Error: Cannot find module 'blob-stream' #14

Closed
guiguipp opened this issue Sep 23, 2022 · 5 comments
Closed

Error: Cannot find module 'blob-stream' #14

guiguipp opened this issue Sep 23, 2022 · 5 comments

Comments

@guiguipp
Copy link

Hmm... I'm a bit confused by this one. Suddenly, my project refuses to build. This is the stack trace I'm getting:

error [...]/node_modules/vite-plugin-shim-react-pdf: Command failed.
Exit code: 1
Command: node scripts/shim-react-pdf.js
Arguments:
Directory: [...]/node_modules/vite-plugin-shim-react-pdf
Output:
internal/modules/cjs/loader.js:905
  throw err;
  ^

Error: Cannot find module 'blob-stream'
Require stack:
- [...]/node_modules/vite-plugin-shim-react-pdf/scripts/shim-react-pdf.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.resolve (internal/modules/cjs/helpers.js:99:19)
    at prependFiles ([...]/node_modules/vite-plugin-shim-react-pdf/scripts/shim-react-pdf.js:25:26)
    at Object.<anonymous> ([...]/node_modules/vite-plugin-shim-react-pdf/scripts/shim-react-pdf.js:43:1)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '[...]//node_modules/vite-plugin-shim-react-pdf/scripts/shim-react-pdf.js'
  ]
}

This happens with:

  • @react-pdf/renderer@3 or @2.3
  • vite @2.9.10

I am unable to run yarn add vite-plugin-shim-react-pdf
Not sure how to resolve this ...or even make it reproductible. As "blob-stream" isn't even a dependency of the shim (that I know of). Mostly wanting to see if anyone is encountering this, I guess... ?

@abeppler
Copy link

it's happening with me too

@guiguipp
Copy link
Author

guiguipp commented Oct 5, 2022

Ok, I was wrong: seems to be specific to @react-pdf/renderer version ^3. I ...looked at many things, including issues reported building after the upgrade to version 3 some users reported with Webpack (we use both vite and webpack in our project, for different exports so, could have been that) to no avail.
Eventually, I had to remove vite-plugin-shim-react-pdf altogether and (temporarily?) opt for that work-around: diegomura/react-pdf#1317 (comment)
Hoping that helps anyone else... (@abeppler)

@carlobeltrame
Copy link
Contributor

The goal with diegomura/react-pdf#1891, which eventually ended up in @react-pdf/renderer v3.0.0, was to make this shim plugin obsolete. If you upgrade to 3.0.0, you should be able to safely and completely remove this shim. The workaround from my comment diegomura/react-pdf#1317 (comment) isn't necessary anymore either.

Previously, react-pdf had blob-stream as a dependency, and this shim used it in some more places where react-pdf was not browser bundler compatible out of the box. In diegomura/react-pdf#1891 I fixed all these incompatibilities directly in react-pdf, so the shim is no longer necessary.

@thekevinbrown
Copy link
Member

Thanks @carlobeltrame, I'll mark this shim as obsolete on NPM and here. A proper upstream fix is way better than a shim always.

@thekevinbrown
Copy link
Member

Done, thanks again!

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

No branches or pull requests

4 participants