Repository navigation
[Sveltekit v next.175+ with Netlify adapter] Cannot find module 'stream/package.json' #2523
Copy link
Copy link
Closed
Labels
Milestone
Description
Describe the bug
Builds now fail on Netlify since version next.175. Local builds still work, and Netlify builds work with version next.174. I have another Sveltekit project that runs on Vercel and I have no build problems there.
I would like to provide more detail but I have no idea what's going on here. I provided the error log below.
Reproduction
This is a reproduction repo: https://github.com/f-elix/sveltekit-netlify-build-fail
It's essentially the Sveltekit demo app with netlify-adapter. I tried to deploy it on Netlify and got the same error as my main project.
Logs
11:36:32 AM: ────────────────────────────────────────────────────────────────
11:36:32 AM: Dependencies installation error
11:36:32 AM: ────────────────────────────────────────────────────────────────
11:36:32 AM:
11:36:32 AM: Error message
11:36:32 AM: A Netlify Function failed to require one of its dependencies.
11:36:32 AM: Please make sure it is present in the site's top-level "package.json".
11:36:32 AM: In file "/opt/build/repo/.netlify/functions-internal/__render.js"
11:36:32 AM: Cannot find module 'stream/package.json'
11:36:32 AM: Require stack:
11:36:32 AM: - /opt/buildhome/.netlify-build-nvm/versions/node/v12.22.6/lib/node_modules/@netlify/build/node_modules/@netlify/zip-it-and-ship-it/src/node_dependencies/resolve.js
11:36:32 AM: - /opt/buildhome/.netlify-build-nvm/versions/node/v12.22.6/lib/node_modules/@netlify/build/node_modules/@netlify/zip-it-and-ship-it/src/node_dependencies/index.js
11:36:32 AM: - /opt/buildhome/.netlify-build-nvm/versions/node/v12.22.6/lib/node_modules/@netlify/build/node_modules/@netlify/zip-it-and-ship-it/src/main.js
11:36:32 AM: - /opt/buildhome/.netlify-build-nvm/versions/node/v12.22.6/lib/node_modules/@netlify/build/src/plugins_core/functions/index.js
11:36:32 AM: - /opt/buildhome/.netlify-build-nvm/versions/node/v12.22.6/lib/node_modules/@netlify/build/src/commands/get.js
11:36:32 AM: - /opt/buildhome/.netlify-build-nvm/versions/node/v12.22.6/lib/node_modules/@netlify/build/src/core/main.js
11:36:32 AM: - /opt/buildhome/.netlify-build-nvm/versions/node/v12.22.6/lib/node_modules/@netlify/build/src/core/bin.js
11:36:32 AM: System Info
System:
OS: Windows 10 10.0.19042
CPU: (8) x64 Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
Memory: 24.27 GB / 39.76 GB
Binaries:
Node: 14.15.5 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.10 - C:\Program Files\nodejs\yarn.CMD
npm: 6.14.11 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.19041.1023.0), Chromium (94.0.992.31)
Internet Explorer: 11.0.19041.1202
npmPackages:
@sveltejs/adapter-netlify: ^1.0.0-next.31 => 1.0.0-next.31
@sveltejs/kit: ^1.0.0-next.175 => 1.0.0-next.175
svelte: ^3.43.0 => 3.43.0Severity
blocking an upgrade
Additional Information
No response
Reactions are currently unavailable
Activity
tomatrow commentedon Sep 29, 2021
Hi,
I had this problem too,
npm i -D streamshould fix it.I think the last time I encountered this, it was because of hidden dependencies in
node-fetch.e.g. #1925
rchrdnsh commentedon Sep 29, 2021
I had the same issue and installing stream fixed it for me as well...
we will need to make a note of this in the docs for the netlify adapter, no?
Or is this something that can be fixed in kit?
benmccann commentedon Sep 29, 2021
This may be related to rollup/plugins#1004, so perhaps this will be fixed when rollup/plugins#1005 is merged and then Vite is upgraded to use it
niwasmala commentedon Sep 30, 2021
Adding
npm i -D streamdoes solve the problem in netlify build.But when I use SSR and access my application, got
Using @sveltejs/kit@1.0.0-next.176 and svelte@3.43.0.
Any help? Thank you.
f-elix commentedon Oct 1, 2021
@tomatrow Installing
streamfixed it!I'd rather not have this in my dependencies but it's not that big of a problem if it makes things work.
Thanks to all for the answers!
benmccann commentedon Oct 5, 2021
I got a fix into
@rollup/plugin-commonjsand upgraded@sveltejs/kitandviteto use it. Can you try upgrading to1.0.0-next.180which I just released to see if it helps?bekos commentedon Oct 6, 2021
@benmccann Still happening for me with
1.0.0-next.180.JohnRSim commentedon Oct 6, 2021
added
Failed on node16 on netlify.
JohnRSim commentedon Oct 6, 2021
Also tried 1.0.0-next.180 still fails - installing stream for now.
justingolden21 commentedon Oct 7, 2021
Has there been any progress on this bug?
justingolden21 commentedon Oct 7, 2021
Got it working with the following
netlify.tomlAfter a few hours of research and struggling, and a fair number of failed attempts.
Docs: https://docs.netlify.com/configure-builds/file-based-configuration/
borntofrappe commentedon Oct 8, 2021
What worked for me was specifying the
node_bundlertoesbuild, in place of the default value ofzisidocumented for Netlify functions.The entire config file consider the default values for the
buildcommand and node version 14.18.0.Thank you @justingolden21 for the example 👍
Update: I'm using the kit in version 1.0.0-next.180
4 remaining items
benmccann commentedon Oct 12, 2021
175 is the version that upgrades to node-fetch 3.0 final, which pulls in fetch-blob, relying on stream. https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md#patch-changes-7
benmccann commentedon Oct 12, 2021
Here's the contents of the relevant section of
.netlify/functions-internal/__render.jsIt seems like a bug on Netlify's side that upgrading to Node 16 doesn't fix this because
streamis provided by the Node API there: https://nodejs.org/api/stream.html#stream_streamI filed a bug with them: netlify/zip-it-and-ship-it#743
benmccann commentedon Oct 12, 2021
Hmm. I guess my fix to
@rollup/plugin-commonjsdidn't work in this particular scenario as it did in some others because it's esbuild that's hoisting the import this time around. If we're able to turn the adapters into Vite plugin and get rid of esbuild that possibly would fix this. Though I'm not sure exactly what Netlify is trying to do, so there's a pretty decent chance it'd still fail even if we took esbuild out of the loop. This definitely seems like a Netlify bug, so hopefully they'll fix it: netlify/zip-it-and-ship-it#743renefournier commentedon Oct 13, 2021
Hmm, tricky. Jamstack, much as I love it, seems to yield some brittleness in the deploy part.
added hidden dependencies (see sveltejs/kit#2523)
Add stream dependency to resolve deployment issues
benmccann commentedon Oct 20, 2021
There's a PR out that would fix this issue: dependents/node-precinct#88
Update netlify config to use esbuild bundler for functions
Add stream temp fix for sveltejs/kit#2523
benmccann commentedon Nov 4, 2021
This is now working. Existing projects will need to "clear cache and deploy"
samheyman commentedon Jul 6, 2022
Still getting the error with Node 16, Latest SvelteKit, added stream manually (v0.02), added netlify.toml.
Just get the error
Was so excited about trying SvelteKit but not being able to rollout to Netlify is a pain.
Dabugger commentedon Jul 7, 2022
I'm also having the same issue, started today.
benmccann commentedon Jul 7, 2022
There's an open issue for that: #5337