Ignacio Giagante
Ignacio Giagante

Reputation: 434

Edge Function middleware is referencing unsupported modules

Im trying to deploy a storybook on vercel and get the following message error:

enter image description here

the project uses pnpm as package manager. Ive upgraded the last version of NextJs and Clerk, as well as downgrade NextJs, but the build is still crashing.

I found this thread unsupported modules, I tried all the paths discussed there, but I'm still having the same issue.

This is my middleware.ts file:

import { authMiddleware } from '@clerk/nextjs';
import { NextResponse } from 'next/server';
import type { NextFetchEvent, NextRequest } from 'next/server';

export default authMiddleware({
  //@ts-ignore
  afterAuth(auth, req: NextRequest, evt: NextFetchEvent) {
    // handle users who aren't authenticated
    if (!auth.userId && !auth.isPublicRoute) {
      const signInUrl = new URL('/sign-in', req.url);
      // signInUrl.searchParams.set('redirect_url', req.url);
      return NextResponse.redirect(signInUrl);
    }
  },
});

export const config = {
  matcher: ['/((?!.*\\..*|_next).*)', '/', '/(api|trpc)(.*)'],
};

I played with framework presets at vercel too.

enter image description here

I changed NextJs to Storybook, but no luck :(

enter image description here

I hope sb can provide a workaround or nice solution. :)

Upvotes: 7

Views: 2399

Answers (3)

I got the same issue and found something in GitHub

Go to your Project Settings > Build & Development Settings, change the framework presets from Others to Next.js, and do a new deployment to work!

Upvotes: 6

August Lilleaas
August Lilleaas

Reputation: 54603

I just had this exact issue, and it seems to be solved now. I first tried to deploy it as a non-framework static web app with custom build commands. But by removing all of the custom commands, and setting the framework to "Storybook" instead of "Other", everything worked out of the box without any custom setup etc!

Upvotes: 0

Kalp Chaudhary
Kalp Chaudhary

Reputation: 11

Downgrade nextjs version to 13.4.3

I had similar error about unsupported modules in middeleware.ts file. Downgrading the nextjs version worked for me.

Upvotes: 1

Related Questions