Comments (8)
Just following up on this, I ended up removing Nx because it was causing a lot of issues with terraform. Instead, I went with the monorepo structure suggested in https://github.com/martpie/monorepo-typescript-next-the-sane-way where each sub app has it's own package.json
. Since the normal next build
command works with this structure, using this terraform module tf-next build
works okay (I just needed to add the --skipDownload
flag like you suggested, thanks).
from terraform-aws-next-js.
Hi, what normally happens when you run tf-next build
is that it copies most of the directory into a temporary folder and then builds it inside the temporary folder.
This can break some more complex monorepo setups like yours.
Since we also use it in a more complex monorepo setup we have added the --skipDownload
flag which prevents the copying into the temporary directory and builds it in place instead.
So what I think would work for you is executing npx tf-next build --skipDownload
inside the web/apps/app1
package and web/apps/app2
directories.
tf-next
can somehow only build one app the the time, so for this setup you have to build both apps separately as mentioned above.
from terraform-aws-next-js.
Thanks for the update π
Yes, we found some issues in the current monorepo support, so there will be an update on this soon.
You can follow #93 for more information.
from terraform-aws-next-js.
Hi there,
sorry to resurrect this issue :-)
It would be great to have this also working with nx monorepo. Not sure if the last comment suggested the opposite.
Thanks for this great tool too!
from terraform-aws-next-js.
@olivark
Ah, I thought that the problem with nx was also fixed with #93.
Never worked with nx, is it using yarn under the hood (like Lerna does) or is it using it's own package manager?
Need to take a closer look at an Next.js + nx example, if you know know one I would appreciate if could drop me a link :)
from terraform-aws-next-js.
@ofhouse
I ended up learning terraform. Now I can deploy to aws and serve my app via cloudfront+s3.
Also I quickly created this (nx, nextjs, terraform-aws-next-js, change package.json and add main.tf)
https://github.com/olivark/nx-nextjs.git
Just run yarn or npm install then yarn tf-next
you should get this:
Build failed:
NowBuildError: A "routes-manifest.json" couldn't be found. This is normally caused by a misconfiguration in your project.
Please check the following, and reach out to support if you cannot resolve the problem:
1. If present, be sure your `build` script in "package.json" calls `next build`. 2. Navigate to your project's settings in the Vercel dashboard, and verify that the "Build Command" is not overridden, or that it calls `next build`. 3. Navigate to your project's settings in the Vercel dashboard, and verify that the "Output Directory" is not overridden. Note that `next export` does **not** require you change this setting, even if you customize the `next export` output directory.
at Object.getRoutesManifest (/Users/kolivar/src/happynrwl/node_modules/@dealmore/tf-next-runtime/dist/index.js:38096:15)
at async Object.build (/Users/kolivar/src/happynrwl/node_modules/@dealmore/tf-next-runtime/dist/index.js:36062:28)
at async Object.buildCommand [as default] (/Users/kolivar/src/happynrwl/node_modules/tf-next/dist/commands/build.js:136:29) {
hideStackTrace: true,
code: 'NEXT_NO_ROUTES_MANIFEST',
link: 'https://err.sh/vercel/vercel/now-next-routes-manifest',
action: undefined
I tried with --skipDownload and did not work either. Maybe there is a way to force nx to run next build instead of nx build somehow.
Anyway, thanks!
from terraform-aws-next-js.
Hey @ofhouse, I'm currently in the same boat( I want to use tf-next with Nx js mono repo strucure).
Is there a way I could help you with this ticket ?
@olivark
Ah, I thought that the problem with nx was also fixed with #93.
Never worked with nx, is it using yarn under the hood (like Lerna does) or is it using it's own package manager?Need to take a closer look at an Next.js + nx example, if you know know one I would appreciate if could drop me a link :)
Regardint this question it uses what ever package manager you tell it to use (npm or yarn). It uses npm by default.
from terraform-aws-next-js.
I think I found a way to get this module working with a Nx monorepo, though it is a bit of a hack.
By adding the following target to my project.json file it becomes possible to run nx package
and the deployment.zip file gets built as expected.
"package":{
"executor":"nx:run-commands",
"options":{
"commands":[
"npx tf-next build --skipDownload",
"rm package.json",
"rm package-lock.json",
"mv next.config.__vercel_builder_backup__.js next.config.js"
],
"cwd":"apps/example-next-app",
"parallel":false
}
}
It is necessary to add the skip download flag or you get a NEXT_NO_VERSION error which I guess is just because the package.json file isn't at the root of the app but at the top of the monorepo. It's then necessary to cleanup the changes that the build command makes to your repository so you don't accidentally commit.
from terraform-aws-next-js.
Related Issues (20)
- This site canβt be reached HOT 1
- Modify proxy to force a version change HOT 1
- Unable to attach policy to lambda, since the iam.tf is missing in all versions starting from 1.0.0-canary.2 HOT 1
- Error: Authentication Failed Returns Status Code 0
- What services does this library use internally to manage deployments? HOT 1
- Unable to use redirect inside getServerSideProps HOT 3
- [Bug] Error while using middleware from Next 12.2 HOT 1
- TimeoutError: Promise timed out after 300000 milliseconds HOT 1
- Question: how can I use this module if I am using Cloudflare for DNS management and WAF? HOT 2
- Dynamic Routes like [id].tsx doesn't be update in my github action
- Q: What permissinos are needed for deployment? HOT 1
- Next.js v13 support HOT 10
- One or more of the CNAMEs you provided are already associated with a different resource. HOT 1
- Cannot deploy - .next-tf/lambdas\__NEXT_PAGE_LAMBDA_0.zip: no such file or directory HOT 1
- Is there a localstack sample available? HOT 1
- Getting Error during creating resources with terraform
- Deployment not deletes old files from s3 HOT 1
- NextAuth CLIENT_FETCH_ERROR , NEXTAUTH_URL
- New deployments not possible due as AWS ACLs are disabled by default HOT 1
- Alternatives? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terraform-aws-next-js.