zip-it-and-ship-it: `Cannot find module` error for Node-provided package

- Do you want to request a feature or report a bug? bug

- What is the current behavior? build fails with error Cannot find module 'stream/package.json'

- If the current behavior is a bug, please provide the steps to reproduce.

- What is the expected behavior?

There should be no need to install a stream package because it is provided by Node: https://nodejs.org/api/stream.html#stream_stream

I’m not sure why it’s trying to find stream/package.json and failing since this is a built-in package

- Please mention your node.js, and operating system version.

Node 16. Linux

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (5 by maintainers)

Most upvoted comments

This is now working. Existing projects will need to “clear cache and deploy”

Thanks for all the help!!

Did some more digging. This error happens when you’re using zip-it-and-ship-it’s dependency resolution mechanism, which uses the Node’s builtin process.binding("natives") to get a list of which dependencies are native (like fs or path or stream/web) and which are not (like react or is-even). Relying on process.binding("natives") means that it depends on whatever Node version is used to do the bundling. Since stream/web, which is used by your dependency fetch-blob, is a Node v16 feature, it rightfully fails (aws lambda, and by extension netlify functions, don’t yet support Node v16). What zip-it-and-ship-it doesn’t detect: fetch-blob accounted for that to happen, and has a fallback strategy. So it fails wrongfully.

You can unblock yourselves by using the esbuild bundler (which I see you already found out via https://github.com/sveltejs/kit/pull/2605). In your case @marovargovcik this has the additional upside of replacing the rollup bundling stage altogether, since esbuild does all the things rollup does for you.