opennextjs-netlify: 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`.
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
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 18 (2 by maintainers)
hey all! thanks for your patience on this. per matt’s issue #433, we’ll close this in favor of that. please follow along and leave feedback there, but we’ll try to circle back here, too, whenever we release support! 🙏
I’ve written up a summary of this and related issues, along with some potential solutions in a new issue: #433
@pzi yep thats basically what we go over here: https://github.com/netlify/netlify-plugin-nextjs/issues/323#issuecomment-859208810 😃
Oh, I totally agree I shouldn’t have to set the distDir to go one dir up 😃 I just did that to check if the plugin considers the publish dir.
Unfortunately, for now at least, the repo is private and I can’t share it.
I will give the changes and maybe esbuild a try later, thanks for looking into it!
@davidli108 my suggestions right now:
frontendin netlifyfrontend/.next