Reputation: 670
I am getting this error during build time because of Next.js custom document.
So, during the build time I am getting an error saying, Also I have the _document.js
in pages/_document.js
.
next/document should not be imported outside of pages/_document.js. See https://nextjs.org/docs/messages/no-document-import-in-page.
Please help me!
EDIT
Update next and eslint-config-next to version 11.1.3-canary.7
Upvotes: 21
Views: 19978
Reputation: 1011
A known issue that is fixed in #28596
If you don't want to update to the canary versions and still keep working normally just exclude it from your .eslintrc.json
rules:
"rules": {
"@next/next/no-document-import-in-page": "off"
}
More info on how to exclude rules here: disabling-rules
Upvotes: 31
Reputation: 8422
Quote from Nextjs team:
This is fixed in #28745 and works in 11.1.3-canary.7. Please upgrade to that version if you're experiencing this issue and if you're still seeing the same error, make sure to clear your cache (next lint --no-cache).
You need to update Nextjs
and eslint-config-next
to 11.1.3-canary.7 and don't forget to clear cache next lint --no-cache
Upvotes: 12