-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node Adapter: "Dynamic require of "x" is not supported" #1733
Node Adapter: "Dynamic require of "x" is not supported" #1733
Comments
Do you have any ideas on how I could clarify this? Any thoughts on what might be causing it? I'm happy to experiment with it, but I've tried all sorts of stuff and I can't figure out the cause. |
Aha! I made a new discovery -- this might suggest that the issue I was seeing is more of a feature than a bug. Coming from the React world where we pretty much just throw everything into This doesn't explain why the issue doesn't crop up in a minimal example when creating a new template app... but it at least fixes my problem. If you're happy with that explanation, feel free to close the issue and we can leave this here for any other hapless fools who try to bundle node-only libs in their |
I can repro this, I assumed it's because I have a fairly old version of Node: 12.21.0 but I guess not. I'll see if I can repro with a stock SvelteKit demo app... |
I'm on 14.x in my project. |
Same here :'( when i've tried to use sharp. But it seems to appear when you |
Same here, I found hints here to make it work.
We use similar dependencies too and had to move them to @tcc-sejohnson : do you run it on an Azure app service or Azure functions ? (also I could be interested in some info about azure-msal integration ! :) ) |
Agreed, documentation on what should/shouldn't be in which dependencies categorization would be nice. Yes, I run my backend on Functions and my frontend on App Service. I store user sessions in Azure Tables. MSAL was a huuuuuge pain to integrate 🙄 Documentation sucks. I'd be happy to share what I got working for us! |
Getting same error only on production mode (node build) with this versions of sveltekit and adapter node. On my local development if I run npm run build and npm run preview it works.
0|genesis- | at async Object.loadESM (internal/process/esm_loader.js:68:5)
0|genesis- | file:///Volumes/BK/clients/genesis/genesis-sveltekit/genesis-client/build/index.js:28
0|genesis- | throw new Error('Dynamic require of "' + x + '" is not supported');
0|genesis- | ^
0|genesis- |
0|genesis- | Error: Dynamic require of "stream" is not supported
0|genesis- | at __require (file:///Volumes/BK/clients/genesis/genesis-sveltekit/genesis-client/build/index.js:28:9)
0|genesis- | at node_modules/node-fetch/lib/index.js (file:///Volumes/BK/clients/genesis/genesis-sveltekit/genesis-client/build/index.js:182:35)
0|genesis- | at __require2 (file:///Volumes/BK/clients/genesis/genesis-sveltekit/genesis-client/build/index.js:31:44)
0|genesis- | at node_modules/isomorphic-fetch/fetch-npm-node.js (file:///Volumes/BK/clients/genesis/genesis-sveltekit/genesis-client/build/index.js:1223:21)
0|genesis- | at __require2 (file:///Volumes/BK/clients/genesis/genesis-sveltekit/genesis-client/build/index.js:31:44)
0|genesis- | at file:///Volumes/BK/clients/genesis/genesis-sveltekit/genesis-client/build/index.js:7103:42
0|genesis- | at ModuleJob.run (internal/modules/esm/module_job.js:152:23)
0|genesis- | at async Loader.import (internal/modules/esm/loader.js:166:24)
0|genesis- | at async Object.loadESM (internal/process/esm_loader.js:68:5)
|
ok figure this out to, by moving most of the package in devDependencies to dependencies. |
@tcc-sejohnson |
Can confirm that issue. For me the following packages were problematic and mas to be moved into the
|
Describe the bug
Unfortunately, I can't provide much insight into what exactly causes this bug, but it's been infuriating me for several hours now.
My app works great using both
svelte-kit dev
andsvelte-kit preview
. My app builds just fine:svelte-kit build
outputs a beautifulbuild
folder. Trying to run the site usingnode build/
, however, blows up. I have no idea why this started -- the library it's complaining about worked about two weeks ago, and I haven't updated the library. The library in question is also only referenced inhooks.ts
and in endpoint files.I can't figure out how to reproduce this in a repo -- there are so many variables at play here, and I don't have enough knowledge to figure it out -- but through exhaustively stepping through my commits to find exactly when the issue started, I've pinned it down to a specific commit for
adapter-node
: 0b780a6. The commit before that works, any commit after doesn't. This coincides with version1.0.0-next.25
ofadapter-node
. I've also tried using1.0.0-next.26
, and that has the same error.Unfortunately, I have some private info on the project I'm having this issue with, but I would be happy to hop on a call with somebody more knowledgable and show the error.
Logs
This is the line of the file causing the issue:
var util = require('util');
.To Reproduce
Not sure... I'm sure if I picked my app apart piece by piece I could narrow it down, but I've been at it for hours and I still don't have a clue what actually causes this. I've gone so far as to completely purge the offending library (just for testing), and the same error will pop up for a new library.
Expected behavior
My build to run!
System:
OS: Linux 5.8 Pop!_OS 20.04 LTS
CPU: (12) x64 AMD Ryzen 5 5600X 6-Core Processor
Memory: 9.06 GB / 31.37 GB
Container: Yes
Shell: 5.0.17 - /bin/bash
Binaries:
Node: 14.16.1 - ~/.nvm/versions/node/v14.16.1/bin/node
Yarn: 1.22.10 - ~/.nvm/versions/node/v14.16.1/bin/yarn
npm: 7.15.0 - ~/.nvm/versions/node/v14.16.1/bin/npm
Browsers:
Chromium: 83.0.4103.116
Firefox: 89.0.1
npmPackages:
@sveltejs/adapter-node: next => 1.0.0-next.26
@sveltejs/kit: next => 1.0.0-next.115
svelte: ^3.38.2 => 3.38.2
Severity
Gamebreaking -- the app doesn't work after build!
The text was updated successfully, but these errors were encountered: