In this very practical tutorial , you will learn how to install and setup angular it in your favorite linux distribution. In my case , it’s tested on ubuntu.
Angular is both a platform and a framework for creating one-page client web applications. It is often used to manage the front-end as we say in IT.
We are not going to dwell on the advantages and disadvantages of the latter in this tutorial.
This information can be found on the website angular.io .
How to install and setup angular in linux
We assume that you are a developer and want to quickly set up an angular project in your debian-like linux.
To start we will first install AngularCli which is a project management tool. Next we will set up a workspace to create a basic Angular application and at the end we will launch the application.
NB: since we are in a linux system, the terminal will be used throughout the tutorial to enter commands. Make sure to launch it from your menu or using the shortcut Ctrl + Alt + T.
Installing Angular Cli in ubuntu
Angular cli makes it easy to create projects and generate source codes to advance faster in development.
We can use angular cli to manage the testing, packaging and deployment of the project. To install it you have to follow the following steps:
- install node js:
sudo apt-get install nodejs
- Install angular now with this command :
npm install -g @ angular / cli
Most of the time, as in our case, we had a permission problem.
In case of an error like ”Error: EACCES: permission denied, access’ / usr / local / lib / node_modules”, run the last command in administrator mode.
sudo npm install -g @ angular / cli
Creation of workspace
We develop applications in the Angular workspace. To create it, you must:
- Create the folder that will be used as a workspace:
- Go to the folder:
- Create the application project with the command:
ng new my app
my app is the name of the application you want to create. If you encounter an error in this step, check our post The Angular CLI requires a minimum of Node.js Version Either *** to get the solution.
- The previous command ng new my-app will launch a series of questionnaires whose answers will allow you to configure the application being created.
- Accept the default configuration by pressing Enter button
The angular cli tool will install npm packages required for the project with its dependencies. This may take a few minutes.
Once the order is complete, your new workspace containing your first ready-to-use application is created.
Launch the application
The angular Cli tool contains a waiter allowing to build and deploy our application locally. To do this follow the following steps:
- Navigate to the workspace folder you created
- Run these commands:
cd my app ng serve --open
This last command will launch the server and automatically display your first page in the browser under the link http: // localhost: 4200 /.
If everything works fine, you will see a page similar to ours:
Now your angular web app work well, you might want to learn more about angular if it’s your first time you work with this framework.
If it’s your case , learn foundation and architecture of angular to understand and get intuition behind angular’s projects.
After this post, you will build angular’s apps with the right mindset!!
Happy coding !!