Categories: Angular

How to create a new Angular project

With Angular CLI you can bootstrap a new project effortlessly. Let’s create a new Angular 6 application complemented with Bootstrap 4 and Sass preprocessor.

Requirements

Create a fresh project

Run the following command to generate a fresh project:

$ ng new awesome-project --style=scss

Go to the project main directory:

$ cd awesome-project

A git repository has been already initialized:

$ git status
On branch master
nothing to commit, working tree clean

$ git log
commit 2e6e36ec34282b83658d2e4e7a26a39e79f38791 (HEAD -> master)
Author: little_pinecone
Date:   Thu Aug 30 10:57:23 2018 +0200

    initial commit

npm allows you to fix some known vulnerabilities found in the project dependencies, you can run the following command:

$ npm audit fix

This command automatically eliminates well-acknowledged javascript vulnerabilities by updating those faulty libraries versions that don’t introduce braking changes.

Remember to commit the adjustments made in the package.json file:

$ git status
modified:   package-lock.json
modified:   package.json

$ git add -A
$ git commit -m "npm packages updated"

Install Bootstrap

To add the latest version of the Bootstrap styles to the project, run the following command:

$ npm install bootstrap

Add the following path in the angular.json file:

// angular.json
…
"styles": [
    …
    "node_modules/bootstrap/scss/bootstrap.scss"
],
…

Start the Angular server to make sure that the project was successfully created:

$ ng serve --open
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

Photo by Autri Taheri on StockSnap

little_pinecone

Share
Published by
little_pinecone

Recent Posts

Simplify the management of user roles in Spring Boot

Spring Security allows us to use role-based control to restrict access to API resources. However,…

3 years ago

Create a custom annotation to configure Spring Boot tests

A custom annotation in Spring Boot tests is an easy and flexible way to provide…

3 years ago

Keycloak with Spring Boot #4 – Simple guide for roles and authorities

Delegating user management to Keycloak allows us to better focus on meeting the business needs…

3 years ago

Keycloak with Spring Boot #3 – How to authorize requests in Swagger UI

Swagger offers various methods to authorize requests to our Keycloak secured API. I'll show you…

3 years ago

Keycloak with Spring Boot #2 – Spring Security instead of Keycloak in tests

Configuring our Spring Boot API to use Keycloak as an authentication and authorization server can…

3 years ago

Keycloak with Spring Boot #1 – Configure Spring Security with Keycloak

Keycloak provides simple integration with Spring applications. As a result, we can easily configure our…

3 years ago