Open 4r7if3x opened 1 year ago
Well, I figured out another way that worked for me... I ran the first command without any options and initiated the workspace with an angular app. Only then I could use nx generate app
to add any sort of extra apps successfully (even a second angular web app).
$ pnpx create-nx-workspace@latest
> NX Let's create a new workspace [https://nx.dev/getting-started/intro]
✔ Choose your style · integrated
✔ What to create in the new workspace · angular
✔ Repository name · app
✔ Application name · web
✔ Default stylesheet format · scss
✔ Enable distributed caching to make your CI faster · Yes
> NX Nx is creating your v15.0.13 workspace.
To make sure the command works reliably in all environments, and that the preset is applied correctly,
Nx will run "pnpm install" several times. Please wait.
✔ Installing dependencies with pnpm
✔ Nx has successfully created the workspace: app.
✔ NxCloud has been set up successfully
Just one question remains... I ended up using xplat after watching NativeScript's webinar on Code Sharing and reading its v5 documentation on this subject, although the latest docs at this moment are for v7. In the webinar, the idea was reusing the code, but using xplat I noticed that doesn't apply in the same way, and things are totally separated in different app directories and there was no obvious relation at first glance. Only for the Electron app, I was asked to provide the name of the web project, and I'm not yet sure how they are connected in this setup.
May you please shed some light on this matter? My goal is to build all web, mobile, and desktop apps using a single Angular codebase and have codes & configurations shared among them as much as possible, yet having a proper, maintainable, and scalable architecture.
I am still struggling to get this to work as well, because my existing angular app is structured like Manfred suggests, and this architecture needs you to think in a different way. See https://youtu.be/4Ee96X6W3Nc I managed to hack all the Xplat includes to from the Core Module and ending up with my web architecture. It works well with both Electron and Web, but with NS I have no idea how to do it. There are some previous threads about the structure of Xplat, discussing this issue. Not sure this is what you are asking about, but for me it's quite a challenge to get to work.
Well, I guess I'd take the official approach to use NativeScript with Angular, for now. I'd recommend it to you as well. It's the same method explained in the webinar and you can follow the instructions from the docs in order to set it up on your existing project.
Yet I'd like to learn more about xplat architecture and its approach and advantages if the authors join this conversation... But I'd like to have shared codes between my projects, not only a monorepo with separated codes in it.
Turned out I was on NodeJS v18 while Angular v15 wasn't released yet to support it, but now it works just fine. I'd suggest handling such errors with a proper message to prevent confusion for newbies in the future.
This is my first time trying to work with
NX
&xplat
, but I couldn't have a successful installation, unfortunately. I'm mainly usingpnpm
as my default package manager, but the result was the same when I tried it withnpm
andyarn
.Here are the global packages that are currently installed with all the package managers:
And here is what I've done in order to set my project up:
I have to add that using
pnpm nx
doesn't make any difference. It only makes sense if I don't havenx
globally and I'd need to run it from the project dependencies, yet even in that case, the installation fails with the same result.Here is the result of
nx report
for your reference: