Project Directory Overview
When we create an Angular project using the ng new
command, it generates a structured set of files and folders. Below is a brief description of some key components:
1. node_modules
Folder
- Contains all third-party libraries installed via npm.
- Should not be checked into version control (e.g., Git).
- If deleted, it can be restored by running
npm install
.
2. package.json
File
- Specifies the project's dependencies and scripts.
- Contains two sections: dependencies (required for running the app) and devDependencies (used during development).
- To install dependencies, use the command:
npm install
.
3. .editorconfig
File
- Defines coding standards for consistency among team members.
- Typically managed by the team lead or project manager.
4. .gitignore
File
- Lists files and folders to be ignored by Git (e.g.,
node_modules
). - Can be customized to exclude unnecessary files.
5. angular.json
File
- Contains project configuration settings.
- Defines stylesheets, scripts, and entry points.
- Specifies the main entry file:
main.ts
.
6. package-lock.json
File
- Ensures the same dependency versions are installed across different environments.
7. tsconfig.json
File
- Defines TypeScript compiler options.
- Determines how TypeScript code is converted into JavaScript.
Understanding the src
Folder
The src
folder contains all the source code for the Angular application. It includes:
1. app
Folder
- Contains application components, services, and modules.
- Every Angular project has at least one module and one component.
2. assets
Folder
- Used for storing static files like images, icons, and text files.
- These files are publicly accessible.
3. Other Important Files
index.html
: Main HTML file loaded when the application starts.main.ts
: Entry point for the application.styles.css
: Global stylesheet for the project.