Visual Studio Code (VSCode) is a popular and versatile open-source code editor developed by Microsoft. It supports a wide range of programming languages and frameworks, including Angular. With its extensive set of features and rich ecosystem of extensions, VSCode is an excellent choice for developing Angular applications. In this article, we will provide a step-by-step guide on how to run an Angular project in Visual Studio Code.
Before you begin, ensure that you have the following software installed on your system:
- Node.js (version 10.9.0 or later)
- Angular CLI (version 8.0 or later)
- Visual Studio Code
Step 1: Create or open an Angular project
If you don’t have an existing Angular project, create one using the Angular CLI. Open your terminal or command prompt and run the following command:
ng new my-angular-app
my-angular-app with the desired name for your project.
To open an Angular project in Visual Studio Code, launch VSCode and click on “File” > “Open Folder…” (or “File” > “Add Folder to Workspace…” if you’re using workspaces). Navigate to the directory containing your Angular project and click “Open.”
Step 2: Install the Angular Language Service extension (optional)
To enhance your development experience in Visual Studio Code, consider installing the Angular Language Service extension. This extension provides advanced features such as IntelliSense, autocompletion, error checking, and quick navigation for Angular templates.
To install the Angular Language Service extension, click on the Extensions view icon in the Activity Bar on the side of the window or press
X. Search for “Angular Language Service” in the Extensions view search bar and click on the “Install” button.
Step 3: Configure the integrated terminal
Visual Studio Code features an integrated terminal that allows you to run commands directly within the editor. To run your Angular project, you’ll need to use the integrated terminal to execute Angular CLI commands.
To open the integrated terminal in Visual Studio Code, click on “Terminal” > “New Terminal” from the top menu or press
Ensure that the integrated terminal is set to use the correct shell for your operating system (e.g., Bash, PowerShell, or Command Prompt). You can change the default shell by clicking on the dropdown menu in the terminal panel or by accessing the VSCode settings (File > Preferences > Settings) and searching for “Terminal > Integrated > Default Profile.”
Step 4: Run the Angular development server
With your Angular project open in Visual Studio Code and the integrated terminal configured, run the following command in the terminal to start the Angular development server:
The Angular CLI will build your application and start the development server. Once the server is running, you should see a message indicating the server’s address (usually
Step 5: View your Angular application in the browser
Open your preferred web browser and navigate to the address displayed in the terminal (e.g.,
http://localhost:4200/). You should now see your Angular application running.
When you make changes to your project files, the Angular development server will automatically rebuild the application and refresh the browser.
Running an Angular project in Visual Studio Code is a straightforward process that involves configuring the integrated terminal and executing Angular CLI commands. By following the steps outlined in this article, you can easily run your Angular applications within Visual Studio Code, allowing you to benefit from the advanced features and rich ecosystem of extensions that this powerful editor offers.