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.
- Create a new SvelteKit project with
npm init svelte@next - Install the Netlify adapter: https://github.com/sveltejs/kit/tree/master/packages/adapter-netlify#installation
- Create an
.nvmrcwith the contents16to use Node 16 - Deploy to Netlify
- 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)
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 (likefsorpathorstream/web) and which are not (likereactoris-even). Relying onprocess.binding("natives")means that it depends on whatever Node version is used to do the bundling. Sincestream/web, which is used by your dependencyfetch-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-blobaccounted for that to happen, and has a fallback strategy. So it fails wrongfully.You can unblock yourselves by using the
esbuildbundler (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 therollupbundling stage altogether, since esbuild does all the things rollup does for you.