next.js: Error: should not be imported outside of pages/_document.
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 21.6.0: Mon Apr 24 21:10:53 PDT 2023; root:xnu-8020.240.18.701.5~1/RELEASE_X86_64
Binaries:
Node: 20.7.0
npm: 10.1.0
Yarn: 1.22.19
pnpm: N/A
Relevant Packages:
next: 13.5.2
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0
typescript: 5.2.2
Next.js Config:
output: N/A
Which example does this report relate to?
npm run build
What browser are you using? (if relevant)
chrome
How are you deploying your application? (if relevant)
No response
Describe the Bug
with next 13.5.2 fresh installation then run build i have this error
same with latest canary 13.5.3-canary.1
after going back to 13.4.19
Expected Behavior
no errors
To Reproduce
npm run build
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Reactions: 1
- Comments: 16 (5 by maintainers)
@ahmedyounes seems I was on the right track š
Hi, I update my reproduction https://github.com/Yovach/nextjs-app-router-document The issue is that Next.js error is unclear.
In my example, it displays :
and
You are using a non-standard "NODE_ENV" value in your environment. This creates inconsistencies in the project and is strongly advised against. Read more: https://nextjs.org/docs/messages/non-standard-node-env
.But if we donāt look at the source code, we donāt know that
NODE_ENV
todevelopment
isnāt compatible withnext build
Related: https://github.com/vercel/next.js/issues/19046
Can confirm. This became issue after upgrading to 13.5.3. I had no issues with building in 13.5.2. Iām using SST to deploy our project to different environments including previews for PRs and deploying them started to fail, because we donāt set NODE_ENV to production. It was working with no issues a day or two ago.
Oops !! Sorry, fixed š
Ok, I just discovered that if I run my
build
command withoutenv-cmd
(I use it to change the env file loaded for build sincenext build
loads automatically.env.production
) it works!!!I also had the message:
That may be a starting point to look for this bug?