Skip to content

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. #390

Closed
@davidli108

Description

@davidli108

Describe the bug
I am using monorepo in my project.
Monorepo foloder structure is

 - app
     - frontend
     - backend

I have netlify.toml file in app folder and next.config.js in frontend folder.

This is next.config.js file

module.exports = {
  target: "experimental-serverless-trace",
  distDir: '.next',
  images: {
    loader: 'imgix',
    path: ''
  }
}

And this is netlify.toml file

[build]
  command   = "npm run lint --prefix frontend && npm run build && npm run test && rm -rf /opt/buildhome/cache"
  publish   = "frontend/out"
  
[context.production.environment]
  NODE_OPTIONS="--max-old-space-size=4096"

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

But I am getting an error as the title of this issue.

Plugin "@netlify/plugin-nextjs" internal error

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.

In "onBuild" event in "@netlify/plugin-nextjs" from netlify.toml
at copyNextAssets (/opt/build/repo/.netlify/plugins/node_modules/@netlify/plugin-nextjs/src/lib/steps/copyNextAssets.js:14:11)
at async build (/opt/build/repo/.netlify/plugins/node_modules/@netlify/plugin-nextjs/src/index.js:25:3)
at async nextOnNetlify (/opt/build/repo/.netlify/plugins/node_modules/@netlify/plugin-nextjs/src/index.js:75:5)
at async onBuild (/opt/build/repo/.netlify/plugins/node_modules/@netlify/plugin-nextjs/index.js:75:5)
at async Object.run (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins/child/run.js:20:3)
at async handleEvent (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins/child/main.js:36:38)
at async process. (/opt/buildhome/.netlify-build-nvm/versions/node/v12.16.3/lib/node_modules/@netlify/build/src/plugins/ipc.js:103:16) 

Expected behavior
A clear and concise description of what you expected to happen.

Versions

  • Next.js: "next": "10.1.3"
  • plugin (if installed at fixed version): "@netlify/plugin-nextjs": "^3.4.2",

If you're using the CLI to build

  • OS: [e.g. macOS, Windows] macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: mediumstatus: needs reproductionthis issue needs to provide a repo that reproduces the bug describedtype: bugcode to address defects in shipped code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions