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.js build is broken since 15.8.7 #15796

Closed
glibvoronin opened this issue Mar 21, 2023 · 2 comments · Fixed by #15824
Closed

next.js build is broken since 15.8.7 #15796

glibvoronin opened this issue Mar 21, 2023 · 2 comments · Fixed by #15824
Assignees
Labels
outdated scope: nextjs Issues related to NextJS support for Nx type: bug

Comments

@glibvoronin
Copy link

Current Behavior

dist/packages/next-app/with-nx.js

contains imports from @nrwl/devkit, @nrwl/workspace/src/utilities/buildable-libs-utils and ../src/utils/config
which are not resolvable when trying to run app in production. Even if @nrwl deps are installed, there is no way to resolve relative import because it's relative to nx sources.

Expected Behavior

STR results in app running

GitHub Repo

https://github.com/glibvoronin/nx-next-build-issue

Steps to Reproduce

  1. nx build next-app
  2. cd dist/packages/next-app && npm i
  3. npm start

Nx Report

Node : 16.17.0
   OS   : darwin arm64
   npm  : 8.15.0
   
   nx                      : 15.8.7
   @nrwl/js                : 15.8.7
   @nrwl/jest              : 15.8.7
   @nrwl/linter            : 15.8.7
   @nrwl/workspace         : 15.8.7
   @nrwl/cli               : 15.8.7
   @nrwl/cypress           : 15.8.7
   @nrwl/devkit            : 15.8.7
   @nrwl/eslint-plugin-nx  : 15.8.7
   @nrwl/next              : 15.8.7
   @nrwl/react             : 15.8.7
   @nrwl/tao               : 15.8.7
   @nrwl/webpack           : 15.8.7
   typescript              : 4.9.5

Failure Logs

> next start

ready - started server on 0.0.0.0:3000, url: http://localhost:3000
error - Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
Error: Cannot find module '../src/utils/config'
Require stack:
- /Users/glibvoronin/projects/nx-next-build-issue/dist/packages/next-app/with-nx.js
- /Users/glibvoronin/projects/nx-next-build-issue/dist/packages/next-app/next.config.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.mod._resolveFilename (/Users/glibvoronin/projects/nx-next-build-issue/node_modules/next/dist/build/webpack/require-hook.js:23:32)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/glibvoronin/projects/nx-next-build-issue/dist/packages/next-app/with-nx.js:8:18)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/glibvoronin/projects/nx-next-build-issue/dist/packages/next-app/with-nx.js',
    '/Users/glibvoronin/projects/nx-next-build-issue/dist/packages/next-app/next.config.js'
  ]
}

Additional Information

Most probably caused by #15650

@nrwl/[email protected] works perfectly fine

@AgentEnder AgentEnder added the scope: nextjs Issues related to NextJS support for Nx label Mar 21, 2023
@FrancisVillarba
Copy link

FrancisVillarba commented Mar 22, 2023

I am experiencing the same issue, doesn't matter if I am using nextJS 12 or nextJS 13.
However, reverting back to @nrwl/[email protected] resolves the build / run issue.

NX Report

   Node : 18.14.0
   OS   : darwin arm64
   npm  : 9.3.1
   
   nx                      : 15.8.6
   @nrwl/js                : 15.8.6
   @nrwl/jest              : 15.8.6
   @nrwl/linter            : 15.8.6
   @nrwl/workspace         : 15.8.6
   @nrwl/cli               : 15.8.6
   @nrwl/cypress           : 15.8.6
   @nrwl/devkit            : 15.8.6
   @nrwl/eslint-plugin-nx  : 15.8.6
   @nrwl/next              : 15.8.6
   @nrwl/react             : 15.8.6
   @nrwl/tao               : 15.8.6
   @nrwl/webpack           : 15.8.6
   typescript              : 4.9.5

Definitely something wrong with #15650

@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated scope: nextjs Issues related to NextJS support for Nx type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants