-
Notifications
You must be signed in to change notification settings - Fork 18
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
Having problems trying to use duckdb-async in Next.js #6
Comments
I tried following the error messages and installing a webpack loader for the HTML dependency and wiring that up in my next.config.js, but that just led to more errors related to some dependencies on At this point I gave up because I don't understand why webpack would need to load a C# file. All the cascading dependency issues seem related to mapbox integration. Is there a way to isolate that functionality? |
I have only done small experiments with Next.js, so forgive any lack of understanding, but...what are you trying to do? duckdb-async is just a thin wrapper around the duckdb node.js bindings ( So the duckdb npm by module (and, by extension, duckdb-async) can only ever run server-side, in a node.js process. Hope that helps. |
You won't be able to get this working 😅—the original DuckDB node package is the issue. I gave up and instead make a post request to a custom lambda layer as explained in this repo. It's not ideal—there's a wasm version too (if it appropriate for your use case). See the node issues here: |
Thanks for your help My main aim here was use duckdb for a database access layer at the server side I endded up writing a separate fastify service to handle my requests works but would have been nice for this to be used in directly in next.js |
I maintain https://www.npmjs.com/package/duckdb-lambda-x86 for exactly the reason @mattf96s explained. I uses the correct GLIBC versions for Vercel (which runs on Lambda). |
but somehow the poster said it doesn't work for duckdb-async, which is weird if this package only is a thin wrapper around duckdb |
Btw, copying my answer from the vercel issue here: If you are on nextjs 14, try this
duckdb-async works with this configuration above on nextjs 14 |
When running on next.js I recieve the following error
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
Import trace for requested module:
./node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html
./node_modules/@mapbox/node-pre-gyp/lib/ sync ^./.*$
./node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js
./node_modules/duckdb/lib/duckdb-binding.js
./node_modules/duckdb/lib/duckdb.js
./node_modules/duckdb-async/dist/duckdb-async.js
./src/app/api/duckdb/route.ts
I have a simple example project showing the problem
https://drive.google.com/file/d/1dceXEXiaH01-SJKxu2ckgoWCTf8f79Rm/view?usp=sharing
unzip form the above link
to reproduce
yarn install
yarn dev
browse to http://localhost:3001/api/duckdb
The text was updated successfully, but these errors were encountered: