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

nextConfig function resolves to wrong path in a monorepo #20142

Closed
2 of 4 tasks
neermitt opened this issue Nov 9, 2023 · 1 comment · Fixed by #20241
Closed
2 of 4 tasks

nextConfig function resolves to wrong path in a monorepo #20142

neermitt opened this issue Nov 9, 2023 · 1 comment · Fixed by #20241
Assignees
Labels
outdated scope: nextjs Issues related to NextJS support for Nx type: bug

Comments

@neermitt
Copy link

neermitt commented Nov 9, 2023

Current Behavior

when nextConfig is provided in monorepo setting, actual path of nextConfig is wrongly evaluated

"configurations": {
        "development": {
          "outputPath": "apps/my-site"
        },
        "production": {},
        "standalone": {
          "nextConfig": "apps/my-site/next.standalone.config.js"
        }
}

results in expected path to be "next.standalone.config.js" from root of workspace

Following errir is received

λ  (Dynamic)  server-rendered on demand using Node.js
 >  NX   Cannot find the Next.js config file: next.standalone.config.js. Is the path correct in project.json?
   Pass --verbose to see the stacktrace.

Expected Behavior

should build standalone nextjs app

GitHub Repo

No response

Steps to Reproduce

  1. Add a new nextjs app in workspace (mono repo)
  2. change production nextConfig to a different path relative to workspace root "app/my-site/next.standalone.config.js"
  3. execute nx run my-site:build:production

Nx Report

Node   : 20.9.0
   OS     : win32-x64
   pnpm   : 8.10.2

   nx                 : 17.0.2
   @nx/js             : 17.0.2
   @nx/jest           : 17.0.2
   @nx/eslint         : 17.0.2
   @nx/workspace      : 17.0.2
   @nx/cypress        : 17.0.2
   @nx/eslint-plugin  : 17.0.2
   @nx/next           : 17.0.2
   @nx/react          : 17.0.2
   @nx/storybook      : 17.0.2
   typescript         : 5.1.6
   ---------------------------------------
   Community plugins:
   @nx-tools/nx-container : 5.1.0

Failure Logs

λ  (Dynamic)  server-rendered on demand using Node.js
 >  NX   Cannot find the Next.js config file: next.standalone.config.js. Is the path correct in project.json?
   Pass --verbose to see the stacktrace.

Package Manager Version

pnpm: 8.10.2

Operating System

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

Additional Information

It seems that nextConfig path is first evaluated relative to the projectRoot and then checked against the workspaceRoot.

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 Dec 16, 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.

3 participants