Skip to content
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

Next.js DaprServer Module not found: Can't resolve 'crypto' #584

Closed
majian159 opened this issue Mar 8, 2024 · 6 comments
Closed

Next.js DaprServer Module not found: Can't resolve 'crypto' #584

majian159 opened this issue Mar 8, 2024 · 6 comments
Assignees
Labels

Comments

@majian159
Copy link

Expected Behavior

Actual Behavior

I'm attempting to start the DaprServer in instrumentation.ts in a Next.js project, but it's throwing an exception:

○ Compiling /instrumentation ...
 ⨯ ./node_modules/.pnpm/@dapr+dapr@3.3.1/node_modules/@dapr/dapr/actors/ActorId.js:15:0
Module not found: Can't resolve 'crypto'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/.pnpm/@dapr+dapr@3.3.1/node_modules/@dapr/dapr/index.js
./src/instrumentation.ts

The code is as follows:

import { CommunicationProtocolEnum, DaprServer } from "@dapr/dapr";

export async function register() {
  const server = new DaprServer({
    serverPort: "4000",
    communicationProtocol: CommunicationProtocolEnum.GRPC,
  });

  await server.start();
}

Steps to Reproduce the Problem

@shubham1172
Copy link
Member

@majian159
Copy link
Author

majian159 commented Mar 18, 2024

This is not helpful; I am using the instrumentation.ts method with Next.js 14 to start the Dapr server.

This is a minimal repo: https://github.com/majian159/dapr-server-example

@shubham1172
Copy link
Member

Thanks for sharing this @majian159, I am out this week but I/someone will check this soon.

@i5shuyi
Copy link

i5shuyi commented May 1, 2024

@shubham1172 My latest pull request replaces the crypto module with crypto. This change will benefit all runtimes compliant with the WinterCG specification (including Next.js Edge Runtime).

@dapr-bot
Copy link
Collaborator

This issue has been automatically marked as stale because it has not had activity in the last 60 days. It will be closed in the next 7 days unless it is tagged (pinned, good first issue, help wanted or triaged/resolved) or other activity occurs. Thank you for your contributions.

@dapr-bot dapr-bot added the stale label Jun 30, 2024
@dapr-bot
Copy link
Collaborator

dapr-bot commented Jul 7, 2024

This issue has been automatically closed because it has not had activity in the last 67 days. If this issue is still valid, please ping a maintainer and ask them to label it as pinned, good first issue, help wanted or triaged/resolved. Thank you for your contributions.

@dapr-bot dapr-bot closed this as completed Jul 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
5 participants