Hi I m new to Nx I wan…
Hi, I’m new to Nx. I want to create a project with a Nest.js as backend and Next.js as frontend but when run nx serve
only Next.js runs.
The steps I follow was:
Create a new project npx create-nx-workspace@latest
and choose “empty”
Install the Next.js plugin yarn add -D @nrwl/next
Generate a Next.js application nx g @nrwl/next:app --style css --linter eslint --name frontend
Install the Nest.js plugin yarn add @nrwl/nest
Generate a Nest.js application nx g @nrwl/nest:app --linter eslint --frontendProject=frontend --name backend
Start the project: yarn start
I want to use Nest.js as backend due its support for Web Socket and Next.js lack of
Responses:
you’ll want to run either nx s frontend
or nx s backend
there is a paramter after serve
which is the name of the app you want to run. If you omit it it just serves the default app, which in your case is the next app
Is there a way to run both
You will need 2 terminals open.
one in each term
but if you absolute need them in the same term you could use something like this: https://www.npmjs.com/package/concurrently
I believed that making backend a dependency of frontend NX would start it automatic
No, it doesn’t work like that.
Thanks
no problem
I managed to run two apps by using the run-many
with the --parallel
nx run-many --target=serve --projects=app1,app2 --parallel
any reason why that shouldn’t work?
Nope, I’m on nx 8 right now. I know nx 9 implements a lot of new run commands especially with the custom run commands. So I think what you are doing is totally fine.