tursodatabase / tursodatabase/libsql
Turborepo, build package, nodeFetch is not a function
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 17.2k
- Forks
- 531
- Avg merge
- 1h 12m
- Merged PRs (30d)
- 1
Description
I'm working on an app, which will go into production testing within 14 days.
I'm running turborepo and I have drizzle / turso running in a separate workspace. Which gets built and used by an application.
When I do not build the package and the gateway in package.json is "main": "/src/index.ts",. Everything works fine.
However, when I build it to simulate production AND to get the types when I import the package. I get the following:
TypeError: nodeFetch is not a function
at fetch (webpack-internal:///(action-browser)/../../node_modules/.pnpm/@libsql+isomorphic-fetch@0.1.10/node_modules/@libsql/isomorphic-fetch/node.cjs:126:12)
at #flush (webpack-internal:///(action-browser)/../../node_modules/.pnpm/@libsql+hrana-client@0.5.5/node_modules/@libsql/hrana-client/lib-cjs/http/stream.js:255:23)
at #flushPipeline (webpack-internal:///(action-browser)/../../node_modules/.pnpm/@libsql+hrana-client@0.5.5/node_modules/@libsql/hrana-client/lib-cjs/http/stream.js:243:20)
at #flushQueue (webpack-internal:///(action-browser)/../../node_modules/.pnpm/@libsql+hrana-client@0.5.5/node_modules/@libsql/hrana-client/lib-cjs/http/stream.js:235:32)
at eval (webpack-internal:///(action-browser)/../../node_modules/.pnpm/@libsql+hrana-client@0.5.5/node_modules/@libsql/hrana-client/lib-cjs/http/stream.js:192:74)
at node:internal/process/task_queues:140:7
at AsyncResource.runInAsyncScope (node:async_hooks:203:9)
at AsyncResource.runMicrotask (node:internal/process/task_queues:137:8)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
⨯ ../../packages/db/dist/index.cjs
Error: Failed to read source code from /Users/paul/development/src/golfcart/packages/db/dist/index.cjs
Caused by:
No such file or directory (os error 2)
Import trace for requested module:
../../packages/db/dist/index.cjs
./src/app/(auth)/signup/actions.ts
Let me know if you require a MVP to take a look.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the failure with the Turborepo package built and imported through packages/db/dist/index.cjs, then inspect the stack locations in @libsql/isomorphic-fetch/node.cjs and @libsql/hrana-client/lib-cjs/http/stream.js. Done means the built package can be imported and used without the “nodeFetch is not a function” error or the missing dist/index.cjs error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, webpack
- Domain
- build-system, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100