-
Notifications
You must be signed in to change notification settings - Fork 207
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
"require is not defined" when initializing DB with d1 beta bindings #400
Comments
My understanding is this PR fixes it: |
Yep, that'll fix it |
Released |
@mrbbot I guess this needs a Miniflare release, and then a Wrangler release? |
You can add a "resolutions": {
"npx-import": "1.1.4"
} |
This should be shipped on any fresh installation of Miniflare/Wrangler - this issue can be closed 🙂 |
I just installed/updated them when I wrote that comment and had to add the resolution. 😕 |
Was trying out the d1 beta bindings in miniflare, and ran into the following:
Seems it's due to this code in
npx-import
, which is a package of"type": "module"
:I believe this needs to be changed to create require:
Tried to patch and write a test for it in the
npx-import
package, but couldn't figure out getting vitest to load the test in a way that it'd fail, whererequire
is undefined. Didn't see a way to force load as a true esm environment, seemsrequire
is always defined in the worker context.The other fix that seemed to work was to change:
miniflare/packages/shared/src/sqlite.ts
Lines 19 to 21 in 974c7c2
to just use
require.resolve
directly:Figured @geelen would know better where is best to fix this, or if there was something else I was missing here where the current code is expected.
The text was updated successfully, but these errors were encountered: