Closed cyrus-za closed 3 years ago
I think nx doesn't allow both and source and build as the same request, I updated the last line so I can build to its normal location and then move it to the required folder as a workaround.
NODE_ENV=production npm run nx -- build $1 --prod
mv -vf dist/apps/$1/.next $2/
mv -vf dist/apps/$1/package.json $2/package.json
Thanks. That solved it for me. I'll keep the issue open until @JamesHenry responds though. Might be a better workaround
Every now and then I get an error that the .next directory already exists. Seems like a vercel caching thing. @akash6190 you running into this too?
The combination of some updates on the Vercel side and this PR: https://github.com/nrwl/nx/pull/4459 will mean that the extra build script should no longer be required and the Vercel UI setup can be simplified.
We have a thread going with Vercel on this, and I will update the instructions as soon as we have confirmation on all sides
I would say just hang tight on whatever works for you in the interim
Hi folks 👋
We have worked together with Vercel to improve the configuration required to deploy Next.js apps on Vercel from Nx workspaces. Additional/custom scripts are no longer required.
Please see the updated guidance here https://github.com/nrwl/nx/pull/4483, it is available for you to implement immediately.
Once the PR is merged, the updated guidance will also be available on https://nx.dev/latest/react/guides/nextjs
Thanks!
Thanks @JamesHenry. That fix works for me. I've left some comments in #3051 for other users with similar issues.
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.
Renovate bot opened a PR to upgrade from 11.0.18 to 11.0.20 and my nextjs build failed with error
I am using @JamesHenry's build-nextjs-app-on-vercel.sh script. The entire next build completes on vercel, but then when it is meant to create the serverless functions on the edges, it throws the above error.
This is most likely relate to https://github.com/serverless-nextjs/serverless-next.js/issues/461
Everything works fine on 11.0.18. I am simply not going to merge that PR in, and keep going until this is solved. I just figured I'd point it out.
PS. I know, I should use
nx migrate
and not manually update deps, which is exactly what I do when I see a nx related PR fromrenovate
. I ran that and there was nomigrations.json
file this time around and no other packages other than those listed above got updated with it, so it's essentially the same PR this time around.