How I fixed @aws-crypto build error
I've been getting the following error when building my Next.js app:
Failed to compile.
./node_modules/.pnpm/@aws-crypto+sha256-js@5.2.0/node_modules/@aws-crypto/sha256-js/build/module/index.js + 12 modules Cannot get final name for export 'fromUtf8' of ./node_modules/.pnpm/@smithy+util-utf8@2.0.2/node_modules/@smithy/util-utf8/dist-es/index.js
I narrowed the source down to the following piece of code:
import { createServerRunner } from "@aws-amplify/adapter-nextjs";
import { AWS_AMPLIFY_CONFIG } from "./utils";
import { cookies } from "next/headers";
import { getCurrentUser } from "aws-amplify/auth/server";
export const { runWithAmplifyServerContext } = createServerRunner({
config: AWS_AMPLIFY_CONFIG,
});