Chapter 2: Getting started: Installing dependencies and creating the project
#
Installations#
NodeJS/AngularIf you already have NodeJS and Angular CLI on your machine, skip this step. Otherwise, do the following:
- Download NodeJS
- Install it on your machine. This may take several minutes
- Install Angular CLI: open your command line tool/terminal and run the following command:
npm install @angular/cli -g
- We are done. You can read more about Angular CLI in the official docs
#
Creating the projectAs I mentioned in the previous chapter, we are going to create an Angular finance logging application with NgRx. Let's create this project and get started:
- Open a preferred directory of yours
- Run the following command
ng new finance-logger
- You can select a number of options, add routing, SCSS, and so on. Those options are irrelevant to this tutorial
- Wait a bit
- Application has been created
Now let's add NgRx to the party:
- Run the command
cd financial-logger
to move to the root directory of our project - Run the command
npm install @ngrx/store
to get NgRx - NgRx consists of several packages, but the most basic functionality is inside
@ngrx/store
. - We will add more packages as we dive into more complex concepts
That's it. Now we have an empty project with NgRx installed.
#
Up and runningIn the app.module.ts
file, add the following import:
import { StoreModule } from "@ngrx/store";
And in the imports
array of the AppModule
declarations, add this line:
@NgModule({ // other metadata imports: [ // other imports StoreModule.forRoot({}), ],})export class AppModule {}
- Run
ng serve
- Open
http://localhost:4200/
- See our fresh Angular app
That's it, we did the basic installations, let's now move on to chapter 3, where we will explore the What.