DEV Community

Muhammad Ahsan Ayaz
Muhammad Ahsan Ayaz

Posted on

5 2 1

How to add Angular to an existing empty NX workspace

Well, this article is about...what the title says :D
I was trying to find this over the internet and couldn't find an easy answer. But with the amazing SEO of Dev.to, I'm really confident that people searching for the same can easily find how to do it.

Problem:

If you have an empty NX repository, i.e. not created with the angular preset, you can't run the following command to create an Angular app:



ng generate app myApp


Enter fullscreen mode Exit fullscreen mode

That's because you'll probably get this error:
Image description

And what it means is that we can't really run ng commands unless we have the angular.json file present in the project's root folder and Angular is already set up. Ergo, we can't add Angular to this empty NX repository this way.

Solution:

You need to install the @nrwl/angular package into the repository as follows:



npm install --save-dev @nrwl/angular
#or
yarn add -D @nrwl/angular


Enter fullscreen mode Exit fullscreen mode

Now you can run the following command to generate an Angular app within the repo. This will also configure the nx workspace to be able to work with Angular apps/libraries.



nx g @nrwl/angular:application myApp


Enter fullscreen mode Exit fullscreen mode

Thank me later :D

Conclusion

If you found the article useful, make sure to hit the like or the bookmark icon. Check out my YouTube Channel for more amazing content. And if you feel adventurous and are interested in taking your #Angular skills to the next level, check out the Angular Cookbook. It's awesome!

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay