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

New nextjs app fails when made from the nx/next CLI #26771

Open
1 of 4 tasks
LukeWood opened this issue Jul 1, 2024 · 0 comments
Open
1 of 4 tasks

New nextjs app fails when made from the nx/next CLI #26771

LukeWood opened this issue Jul 1, 2024 · 0 comments

Comments

@LukeWood
Copy link

LukeWood commented Jul 1, 2024

Current Behavior

Building the site by deafult causes the error:

"
Error: should not be imported outside of pages/_document.
Read more: https://nextjs.org/docs/messages/no-document-import-in-page
"

I've seen some information online that leads me to believe this may be related to the warning:

 ⚠ 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

Which I believe is being triggered due to nx replacing 'process.env.NODE_ENV' with the string literal development.

This happens on every page, and is easy to repo.

Expected Behavior

It should build just fine.

GitHub Repo

https://github.com/nrwl/nx-examples

Steps to Reproduce

  1. pnpm i react@latest react-dom@latest next@latest @types/react@latest
  2. nx g {your next app}
  3. nx build {your next app]

Nx Report

NX   Report complete - copy this into the issue template

Node   : 21.7.3
OS     : darwin-arm64
pnpm   : 8.10.2

nx (global)        : 19.0.2
nx                 : 19.0.2
@nx/js             : 19.0.2
@nx/jest           : 19.0.2
@nx/eslint         : 19.0.2
@nx/workspace      : 19.0.2
@nx/cypress        : 19.0.2
@nx/devkit         : 19.0.2
@nx/esbuild        : 19.0.2
@nx/eslint-plugin  : 19.0.2
@nx/next           : 19.0.2
@nx/node           : 19.0.2
@nx/playwright     : 19.0.2
@nx/react          : 19.0.2
@nx/vite           : 19.0.2
@nx/web            : 19.0.2
typescript         : 5.4.5
---------------------------------------
Registered Plugins:
@nx/vite/plugin
@nx/eslint/plugin
@nx/playwright/plugin
@nx/jest/plugin
@nx/next/plugin

Failure Logs

Error: <Html> should not be imported outside of pages/_document.
Read more: https://nextjs.org/docs/messages/no-document-import-in-page
    at Z (/Users/lukewood/workspace/yeti/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/next-server/pages.runtime.prod.js:16:5430)
    at I (/Users/lukewood/workspace/yeti/apps/lit-games/.next/server/chunks/392.js:6:1263)
    at renderWithHooks (/Users/lukewood/workspace/yeti/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5658:16)
    at renderIndeterminateComponent (/Users/lukewood/workspace/yeti/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5732:15)
    at renderElement (/Users/lukewood/workspace/yeti/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5957:7)
    at renderNodeDestructiveImpl (/Users/lukewood/workspace/yeti/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.browser.development.js:6115:11)
    at renderNodeDestructive (/Users/lukewood/workspace/yeti/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.browser.development.js:6087:14)
    at finishClassComponent (/Users/lukewood/workspace/yeti/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5688:3)
    at renderClassComponent (/Users/lukewood/workspace/yeti/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5696:3)
    at renderElement (/Users/lukewood/workspace/yeti/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.browser.development.js:5954:7)

Package Manager Version

pnpm 8.10.2

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant