Middleware won't deploy in subpath with error no-server-import-in-page with React Server Components and concurrentFeatures
See original GitHub issueWhat version of Next.js are you using?
12.0.8-canary.4
What version of Node.js are you using?
local: 14.8.1 // vercel: 12
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
Vercel
Describe the Bug
When deploying an NextJs App to Vercel, with having a _middleware.js / _middleware.ts in a sub-path of pages, e.g. /pages/dashboard/_middleware.ts
the build fails with:
Error: next/server should not be imported outside of pages/_middleware.js. See https://nextjs.org/docs/messages/no-server-import-in-page. @next/next/no-server-import-in-page
Expected Behavior
Deploy sucessfully
To Reproduce
With: concurrentFeatures: true serverComponents: true
Add: /pages/test/_middleware.js
import { NextResponse } from "next/server";
export default async function middleware(req, event) {
return NextResponse.next();
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
React Server Components in Next.js 12
Next.js 12 includes React Server Components, which enable you to load components faster because computing is shifted away from the client.
Read more >React 18: React Server Components
React Server Components allow developers to build applications that span the server and ... Deploy the app/ directory example to try Server Components....
Read more >Introducing Zero-Bundle-Size React Server Components
As it comes to an end we wanted to share a special Holiday Update on our research into zero-bundle-size React Server Components.
Read more >javascript - Error: `experimental.runtime` requires ...
Remove your package-lock.json and install the canary version of next npm install next@canary react@latest react-dom@latest.
Read more >React Server Components. - It's not server-side rendering.
log(error); }); }, []);. Although there's nothing wrong with that, this data fetching approach will always cost some time to render ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@thibautsabot is totally right.
This has been fixed in
eslint-config-next@12.0.8-canary.0
. Make sure you have that or a newer version!Hey!
Really sorry about the hiccup 🙏 .
I’m unable to reproduce it with
next
andeslint-config-next
on 12.0.8-canary.5 though 😕 . Did you update both packages?