question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Module not found: Error: Can't resolve 'async_hooks' in /node_modules/@prisma/client/runtime when using data proxy

See original GitHub issue

Bug description

Getting error when running

npx wrangler dev

Output

👀  ./node_modules/@prisma/client/runtime/index.js
Module not found: Error: Can't resolve 'async_hooks' in '/mnt/volume_nyc1_01/prisma-mongodb-cloudflare/node_modules/@prisma/client/runtime'
resolve 'async_hooks' in '/mnt/volume_nyc1_01/prisma-mongodb-cloudflare/node_modules/@prisma/client/runtime'
  Parsed request is a module
  using description file: /mnt/volume_nyc1_01/prisma-mongodb-cloudflare/node_modules/@prisma/client/package.json (relative path: ./runtime)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module

snip, it’s very long

[/mnt/volume_nyc1_01/prisma-mongodb-cloudflare/node_modules/util/types]
[/mnt/volume_nyc1_01/prisma-mongodb-cloudflare/node_modules/util/types.ts]
[/mnt/volume_nyc1_01/prisma-mongodb-cloudflare/node_modules/util/types.tsx]
[/mnt/volume_nyc1_01/prisma-mongodb-cloudflare/node_modules/util/types.js]
 @ ./node_modules/@prisma/client/runtime/index.js 33546:27-48
 @ ./node_modules/.prisma/client/index.js
 @ ./node_modules/@prisma/client/index.js
 @ ./src/index.ts
Error: webpack returned an error. Try configuring `entry` in your webpack config relative to the current working directory, or setting `context = __dirname` in your webpack config.

How to reproduce

I am following the instructions here:

https://www.prisma.io/docs/guides/deployment/deployment-guides/deploying-to-cloudflare-workers

My repo is here

https://github.com/coding-to-music/prisma-mongodb-cloudflare

Expected behavior

Initially was working but now I am getting the errors listed above

Prisma information

generator client {
  provider = "prisma-client-js"
  previewFeatures = ["dataProxy"]
}

datasource db {
  provider = "mongodb"
  url      = env("DATABASE_URL")
}

model Log {
  id      String @id @default(auto()) @map("_id") @db.ObjectId
  level   Level
  message String
  meta    Json
}

enum Level {
  Info
  Warn
  Error
}

Environment & setup

  • OS: Debian
  • Database: mongodb
  • Node.js version: v16.14.2

Prisma Version

prisma                  : 3.14.0
@prisma/client          : 3.14.0
Current platform        : debian-openssl-1.1.x
Query Engine (Node-API) : libquery-engine 2b0c12756921c891fec4f68d9444e18c7d5d4a6a (at node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Migration Engine        : migration-engine-cli 2b0c12756921c891fec4f68d9444e18c7d5d4a6a (at node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine    : introspection-core 2b0c12756921c891fec4f68d9444e18c7d5d4a6a (at node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary           : prisma-fmt 2b0c12756921c891fec4f68d9444e18c7d5d4a6a (at node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash    : 2b0c12756921c891fec4f68d9444e18c7d5d4a6a
Studio                  : 0.460.0

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
coding-to-musiccommented, May 23, 2022

1. btw that tutorial

https://www.prisma.io/docs/guides/deployment/deployment-guides/deploying-to-cloudflare-workers

needs a step to tell you to push your schema to the Atlas database, via toggling the DATABASE_URL to not point to the AWS proxy but instead point to Atlas.

Then npx prisma db push

Then the Prisma dashboard will see the schema at the target. Then gotta set the DATABASE_URL back to the Prisma / AWS url.

2. Also, the MongoDB is no longer a preview feature, the guide gives incorrect syntax for

previewFeatures = [“mongoDb”, “dataProxy”]

Should be:

previewFeatures = [“dataProxy”]

1reaction
millspcommented, May 24, 2022

Thanks for your time. We are actively working on fixing Uncaught Error: PrismaClient is unable to be run in the browser. If you’d like to try it, I’ll share an integration version with you in the coming days. I’ll also take a look at wrangler 1 to see if anything needs fixing or needs doc improvements.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Can't resolve 'async_hooks' - Stack Overflow
The problem with 'async_hooks' is that it will only be available in node on serverside - if e.g. webpack tries to create a...
Read more >
Module not found: Can't resolve 'async_hooks' error [Solved]
The error Module not found: Error: Can't resolve 'async_hooks' occurs because there has been a breaking change in Webpack version 5. To solve...
Read more >
How to fix 'Module not found: Can't resolve 'http' in ... - YouTube
Basically, just change 'react-scripts' to 4.0.2 in your package.json and run `npm install` again :D Follow me on Twitter: ...
Read more >
open-telemetry/opentelemetry-node - Gitter
As far as missing features, like you pointed out there is some tooling missing for quickly ... Module not found: Can't resolve 'async_hooks'...
Read more >
Nodejs APM - Can't resolve 'async_hooks' - Elastic Discuss
Hello, We are trying to use APM for our React nodejs app. We have added the dependency ... Module not found: Can't resolve...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found