1. Overview
Angular CLI (Command Line Interface) is a powerful toolset that helps developers initialize, develop, scaffold, and maintain Angular applications. It provides a set of tools to create projects, generate application and library code, perform a variety of ongoing development tasks such as testing, bundling, and deployment.
Installing and using Angular CLI on a Debian machine is a straightforward process but requires careful attention to detail, especially for new developers. This article provides step-by-step instructions to help you set up Angular on your Debian machine.
2. System Requirements
Before installing Angular CLI, ensure your system meets the following requirements:
- Node.js: Angular requires a current, active LTS, or maintenance LTS version of Node.js.
- npm Package Manager: Angular, Angular CLI, and Angular applications depend on npm packages. npm is included with Node.js.
3. Installing Node.js and npm
If Node.js and npm are not installed on your Debian system, you can install them using the following steps:
- Step 3.1: Update Your System: Open a terminal and update your package index:
sudo apt update
- Step 3.2: Setup node.js repository: Setup the required Node.js PPA on your system. You can also use nvm for installing multiple Node versions on single system using this tutorial.
curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -
- Step 3.3: Install Node.js and npm: Install Node.js from the repositories:
sudo apt install nodejs
- Step 3.4: Verify Installation: Check the installed versions of Node.js and npm:
node -v
npm -v
4. Installing Angular CLI
With Node.js and npm installed, you can now install Angular CLI.
- Step 4.1: Install Angular CLI: Use npm to install the Angular CLI globally
sudo npm install -g @angular/cli
- Step 4.2: Verify Angular CLI Installation: To verify that Angular CLI was installed correctly, use the version command:
ng version
5. Creating a New Angular Project
With Angular CLI installed, you can create a new Angular project.
- Step 5.1: Create a Project: Navigate to the directory where you want to create your project and run:
ng new my-angular-project
Replace `my-angular-project` with your desired project name.
- Step 5.2: Navigate into Your Project: Move into your project directory:
cd my-angular-project
6. Serving the Application
To see your new application, you need to run it on a development server.
- Step 6.1: Start the Development Server: Run the following command:
ng serve
- Step 6.2: Open the Application: Open a browser and navigate to http://localhost:4200/. You should see your new app running.
7. Additional Tools and Commands
Angular CLI offers many tools and commands to help develop your application. Some commonly used commands include:
ng generate component component-name
: Generate a new component.ng build
: Build the project.ng test
: Run unit tests.ng lint
: Run linting tools.
8. Conclusion
You have successfully installed Angular CLI on Debian and created a new Angular project. Angular CLI is a robust tool that simplifies the development process. With these tools at your disposal, you can now dive into developing your Angular application.
This guide provides the basic steps to get started with Angular CLI on Debian. As you progress, exploring the Angular CLI documentation and other resources will be beneficial for advanced features and best practices.