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/next/no-server-import-in-page error occurs in nested route #35298

Closed
1 task done
kurone-ab opened this issue Mar 14, 2022 · 2 comments
Closed
1 task done

@next/next/no-server-import-in-page error occurs in nested route #35298

kurone-ab opened this issue Mar 14, 2022 · 2 comments
Labels
bug Issue was opened via the bug report template.

Comments

@kurone-ab
Copy link

kurone-ab commented Mar 14, 2022

Verify canary release

  • I verified that the issue exists in Next.js canary release

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 21.3.0: Wed Jan  5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000
Binaries:
  Node: 16.13.1
  npm: 8.5.4
  Yarn: 3.2.0-rc.10
  pnpm: N/A
Relevant packages:
  next: 12.1.1-canary.10
  react: 17.0.2
  react-dom: 17.0.2

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

./pages/foo/_middleware.ts
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

ESlint error occurs in nested route middleware not root middleware.
I think this error is similar to #32156

Expected Behavior

No lint error

To Reproduce

  1. Create nested foo directory in pages. (e.g. ./pages/foo)
  2. Create _middleware.ts file in foo.
  3. Run yarn lint.
@kurone-ab kurone-ab added the bug Issue was opened via the bug report template. label Mar 14, 2022
@balazsorban44
Copy link
Member

balazsorban44 commented Mar 14, 2022

This has been fixed already, make sure to update eslint-config-next as well!

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

2 participants