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

pages/_document.js throwing no-document-import-in-page #28971

Closed
markxoe opened this issue Sep 9, 2021 · 7 comments
Closed

pages/_document.js throwing no-document-import-in-page #28971

markxoe opened this issue Sep 9, 2021 · 7 comments
Labels
bug Issue was opened via the bug report template.

Comments

@markxoe
Copy link

markxoe commented Sep 9, 2021

What version of Next.js are you using?

11.1.2

What version of Node.js are you using?

16.7.0

What browser are you using?

Firefox

What operating system are you using?

Windows 10

How are you deploying your application?

Only Development

Describe the Bug

I am getting the @next/next/no-document-import-in-page linting error, but I am importing the document module in the pages/_document.js file

Looks funny when displayed:

./pages/_document.js
1:1  Error: next/document should not be imported outside of pages/_document.js. See https://nextjs.org/docs/messages/no-document-import-in-page.  @next/next/no-document-import-in-page

Expected Behavior

Not getting an linting error

To Reproduce

Use a Windows machine, create an Next.js App and create a pages/_document.js file according to the docs (https://nextjs.org/docs/advanced-features/custom-document) and lint using npm run lint

@markxoe markxoe added the bug Issue was opened via the bug report template. label Sep 9, 2021
@ristomatti
Copy link

We're also seeing this with developers on Windows. There's a PR that should fix this already merged #28745, it's part of [v11.1.3-canary.4] release (https://github.com/vercel/next.js/releases/tag/v11.1.3-canary.4).

Curiously, explicitly installing @next/eslint-plugin-next@11.1.3-canary.7fixed this for us while we were on v11.0.1 but now broke again when upgrading to v11.1.2, even if explicitly installing the above package.

@andrei9669
Copy link

#28596

@housseindjirdeh
Copy link
Collaborator

housseindjirdeh commented Sep 14, 2021

@markxoe Which version of eslint-config-next (or @next/eslint-plugin-next) are you using? If you're using an older version than 11.1.3-canary.7, this is likely a duplicate of #28596. Could you:

  1. Upgrade to 11.1.3-canary.7 or a later canary version
  2. Run npm run lint --no-cache to clear the cache

Let me know if you're still seeing this issue after these steps!

@housseindjirdeh
Copy link
Collaborator

Curiously, explicitly installing @next/eslint-plugin-next@11.1.3-canary.7fixed this for us while we were on v11.0.1 but now broke again when upgrading to v11.1.2, even if explicitly installing the above package.

@ristomatti Hmm not sure why v11.1.2 of Next.js would cause the error to re-surface. 🤔

Could you try explicitly upgrading both Next.js and @next/eslint-plugin-nextto the latest canary version (11.1.3-canary.15) and clear the cache (next lint --no-cache). Let me know if you're still seeing this issue after this.

@markxoe
Copy link
Author

markxoe commented Sep 14, 2021

Upgrading eslint-plugin-next did the job 👍

@markxoe markxoe closed this as completed Sep 14, 2021
@ristomatti
Copy link

@housseindjirdeh If I remember correctly, this is what I asked one of the Windows devs to try but can't be sure. We decided to disable the rule for now and see if it gets fixed with the final 11.1.3 (or newer) release. There's a chance this could have been a side effect of npm version mismatch between the devs we noticed a day later

Daniel-McCarthy added a commit to 0xDePaul/0xDePaul-Interface that referenced this issue Sep 19, 2021
Fixes build errors from a defect in dependency by bumping to a fixed version. Issue: vercel/next.js#28971
@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 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

5 participants