-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the bug
When setting up adapter-node I'm configuring a custom entry point copied from the example here: https://github.com/sveltejs/kit/tree/master/packages/adapter-node#middleware but I run into this error when I try to start the server with node build: Dynamic require of "buffer" is not supported.
The error message points to the jsonwebtoken package which I use on some node only endpoints.
But, this is not specific to this package, it's the same with dotenv and other node packages.
If I skip the entryPoint config in the adapter setup, it works.
Reproduction
Minimal repro repo: https://github.com/oskarhane/sveltekit-adapter-node-bug-repro
npm ci
All I've done there is to npm init svelte@next, installing @sveltejs/adapter-node, jsonwebtoken and polka and configured the adapter after creating a single request handler that uses the jwt package.
npm run build
node build
Edit (toggle the comments) the adapter config in svelte.config.js and try again to have it work / not work.
Logs
▶ node build
file:///Users/oskarhane/Development/tmp/sk-bug/build/index.js:13
throw new Error('Dynamic require of "' + x + '" is not supported');
^
Error: Dynamic require of "buffer" is not supported
at file:///Users/oskarhane/Development/tmp/sk-bug/build/index.js:13:9
at node_modules/safe-buffer/index.js (file:///Users/oskarhane/Development/tmp/sk-bug/build/index.js:33:18)
at __require2 (file:///Users/oskarhane/Development/tmp/sk-bug/build/index.js:16:44)
at node_modules/jws/lib/sign-stream.js (file:///Users/oskarhane/Development/tmp/sk-bug/build/index.js:564:19)
at __require2 (file:///Users/oskarhane/Development/tmp/sk-bug/build/index.js:16:44)
at node_modules/jws/index.js (file:///Users/oskarhane/Development/tmp/sk-bug/build/index.js:744:22)
at __require2 (file:///Users/oskarhane/Development/tmp/sk-bug/build/index.js:16:44)
at node_modules/jsonwebtoken/decode.js (file:///Users/oskarhane/Development/tmp/sk-bug/build/index.js:777:15)
at __require2 (file:///Users/oskarhane/Development/tmp/sk-bug/build/index.js:16:44)
at node_modules/jsonwebtoken/index.js (file:///Users/oskarhane/Development/tmp/sk-bug/build/index.js:2835:15)System Info
System:
OS: macOS 11.5.2
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 3.38 GB / 32.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.17.4 - ~/.nvm/versions/node/v14.17.4/bin/node
Yarn: 1.22.11 - ~/.nvm/versions/node/v14.17.4/bin/yarn
npm: 6.14.14 - ~/.nvm/versions/node/v14.17.4/bin/npm
npmPackages:
@sveltejs/adapter-node: ^1.0.0-next.49 => 1.0.0-next.49
@sveltejs/kit: next => 1.0.0-next.171
svelte: ^3.34.0 => 3.38.3 Severity
blocking all usage of SvelteKit
Additional Information
No response