Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 months ago.
I have developed an Angular application using tools such as NPM (I did not use the Angular CLI). What is the best way to migrate the project to the CLI project model? For example, I want to be able to use commands like ng serve
.
To convert an Angular project to use the Angular CLI, you could follow these steps.
1. Install the CLI
npm install -g @angular/cli
2. Create a new CLI Project
ng new my-first-project
cd my-first-project
ng serve
3. Copy your existing code files into the new CLI Project
4. Configure your Angular Workspace
Differences between Angular CLI and Other Build Systems
Notes from Migrating a project to Angular CLI build system
- Angular CLI may use multiple
tsconfig.json
files (be sure to setup dependencies between files correctly)
ng serve
and ng test
compile your typescript into memory rather than physical files.
- If
ng test
doesn't work and gives cryptic errors look into the pollyfills.ts
file and start uncommenting lines.
- Consider locking
package.json
versions with exact version numbers, shrinkwrap, lockfile, or yarn. There is no joy in debugging @types
, tsc versions and incompatible modules.
- Building with
ng build --prod
(which uses AOT compilation) is a lot more strict than the default typescript rules with ng serve
.
- Using sass for css:
- When creating new project:
ng new my-first-app --style=scss
- Or modify
angular.json
:
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
}
}