analogjs / analog

The fullstack meta-framework for Angular. Powered by Vite and Nitro
https://analogjs.org
MIT License
2.51k stars 240 forks source link

Can't create nx workspace with analogjs/platform as preset #883

Closed tmastalirsch-tlv closed 7 months ago

tmastalirsch-tlv commented 7 months ago

Please provide the environment you discovered this bug in.

nx workspace version: v18.0.3 node version: v18.14.0

Which area/package is the issue in?

create-analog

Description

Getting an error by create a new nx workspace with analogjs/platform as preset with below command: npx create-nx-workspace@latest --preset=@analogjs/platform . Latest Version for the workspace is v18.0.3 and node version is v18.14.0.

Please provide the exception or error you saw

>  NX   Let's create a new workspace [https://nx.dev/getting-started/intro]

✔ Where would you like to create your workspace? · analog-nx
✔ Do you want Nx Cloud to make your CI fast? · skip

 >  NX   Creating your v18.0.3 workspace.

✔ Installing dependencies with npm
✔ Successfully created the workspace: analog-nx.
✔ What name would you like to use for your Analog app? · analog-app
✔ Add TailwindCSS for styling? (Y/n) · true
✔ Add tRPC for typesafe client/server interaction? (y/N) · false
Angular has not been installed yet. Creating an Angular application
Fetching @nx/angular...
Fetching @angular-devkit/core...

 >  NX   Invalid version. Must be a string. Got type "object".

   Pass --verbose to see the stacktrace.

 >  NX   Failed to apply preset: @analogjs/platform

   See above

Other information

No response

I would be willing to submit a PR to fix this issue

FrozenPandaz commented 7 months ago

So I see here, that the @analogjs/platform:preset is expecting for @nx/angular:init to install @angular/core into the package.json but that is no longer the case.

We moved that behavior into our application/library generators so that nx add @nx/angular would be more minimal.

Perhaps rather than relying on @nx/angular to add the version, Analog could handle installing @angular/core with whichever version is supported. This will give Analog more control over the version of @angular/core which is installed so there should be no need to check it afterwards.

To debug what is going on, I am running nx g @analogjs/platform:preset --verbose in the workspace which is created.

brandonroberts commented 7 months ago

This is resolved in release 0.2.36. The command below works successfully with Nx 18

npx create-nx-workspace@latest --preset @analogjs/platform@latest --analogAppName analog-app