Closed davidli108 closed 3 years ago
@davidli108 Trigger a build again. I was having this issue and when I simply redeploy from Netlify Dashboard then it works fine for me.
Give it aa try, it might help you as well.
@samiahmedsiddiqui Thanks for your comment. I tried a build several times but I am having same issues.
@samiahmedsiddiqui Could you please share your next.config.js and netlify.toml file? And please check my folder structure and config files. :)
Thank you.
@davidli108 hey david! thanks for opening this issue! do you have your base
directory set in netlify? is there a specific reason you manually set distDir
to '.next(that is what it defaults to). it's possible you might want to set distDir to
frontend/.next`. would be helpful to see your npm scripts too! on top of all those qs, a simple repo would be probably the most helpful :)
@lindsaylevine Thanks for your comment.
I didn't set base
directory.
My issue is happening in this line
Here, staticAssetsPath
is defined like this:
const nextDistDir = await getNextDistDir()
const staticAssetsPath = join(nextDistDir, 'static')
And then, nextDistDir
is defined like this:
So I thought nextConfig.distDir
has a problem.
That's why I set distDir
manually.
I look forward to hearing from you. Thank you
@davidli108 Please add console.log(staticAssetsPath)
and see what it returns.
@davidli108 my suggestions right now:
frontend
in netlifyfrontend/.next
hello! i now believe this is a duplicate of https://github.com/netlify/netlify-plugin-nextjs/issues/323 but would still need a repo to confirm. feel free to close this and follow #323 if you think it's the same issue or want to try the bandaid i offered simon.
I am getting the same error for my monorepo....
When looking into the .next
and .next/static
folders it's all there but the plugin doesn't seem to be able to pick it up...
netlify.toml
[build]
base = "/"
publish = "/web/.next/" # or /web/ for that matter
command = "yarn build-web; ls -alh web/.next/; ls -alh web/.next/static"
[[plugins]]
package = "@netlify/plugin-nextjs"
next.config.js
const nextConfig = {
reactStrictMode: true,
target: 'serverless',
future: undefined,
experimental: undefined,
};
module.exports = nextConfig;
Scripts:
# root
"build-web": "lerna bootstrap && (cd web && yarn build)",
# web
"build": "next build",
monorepo structure:
- repo/
- lerna.json
- package.json
- web/
- package.json
- studio/
- package.json
Looks like I can get it to pick up the files if I set my next.config.js
distDir
to ../.next
which seems to get me a little further but it then breaks because it's missing a dependency:
@pzi hey! thanks for letting us know what's going on in your monorepo setup. helpful for us moving forward! if you wanted to provide us with a repo we can test against once we address all these issues, that would be even more helpful! #323 could possibly guide you on how to set your publish dir and next dist. also, per https://nextjs.org/docs/api-reference/next.config.js/setting-a-custom-build-directory, your distDir should not go up to parent dirs. not sure why you're seeing cannot find module critters, it's an outdated issue 🤔 . possibly try adding esbuild
to your netlify.toml per https://docs.netlify.com/configure-builds/file-based-configuration/#functions. anyways, hang tight~!!
note: esbuild breaks dynamic imports, if you're using those in your site. we're working on a fix for this!
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!
It feels like that something like the below might address the issue we are experiencing?
const getNextDistDir = async (publishPath) => {
const nextConfig = await getNextConfig()
return join(publishPath, nextConfig.distDir)
}
@pzi yep thats basically what we go over here: https://github.com/netlify/netlify-plugin-nextjs/issues/323#issuecomment-859208810 :)
I've written up a summary of this and related issues, along with some potential solutions in a new issue: #433
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! 🙏
Could anyone who experienced this try installing @netlify/plugin-nextjs@latest
and see if it works? Version 3.6.0 adds much better monorepo support. Docs are here
Describe the bug I am using monorepo in my project. Monorepo foloder structure is
I have netlify.toml file in app folder and next.config.js in frontend folder.
This is next.config.js file
And this is netlify.toml file
But I am getting an error as the title of this issue.
Expected behavior A clear and concise description of what you expected to happen.
Versions
If you're using the CLI to build