Skip to content

Deployment broken with Nx #115

Closed
Closed
@ebrehault

Description

@ebrehault

Describe the bug
A typical Next.js app built into an Nx monorepo will be located in a subfolder like ./apps/my-site.
When the next.config.jsfile is not in the project root folder, theonBuild command fails with

Error: No static assets found in .next dist (aka no /.next/static). Please check your project configuration. Your next.config.js must be one of `serverless` or `experimental-serverless-trace`. Your build command should include `next build`.

Using base in netlify.toml [build] section does not fix the problem (but it is not the proper approach according the documentation as it is supposed to target a folder containing package.json, while an Nx project contains its package.json in its root, not in each app folder).

To Reproduce
Steps to reproduce the behavior:

  1. Create a monorepo project with Nx
  2. Add a Next.js site
  3. Publish it on Netlify

Expected behavior
The deployment should work

Versions

  • Next.js: ^10.0.8
  • plugin (if installed at fixed version): ^3.0.0

If you're using the CLI to build

  • OS: [e.g. macOS, Windows]
  • netlify/cli version:

If you're using file-based installation

  • netlify.toml:
[build]
  command   = "npm run build"
  publish   = "dist/apps/basic"

[[plugins]]
  package = "@netlify/plugin-nextjs"

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: featurecode contributing to the implementation of a feature and/or user facing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions