The procedures on this page describe how to check out the Braintree Spartacus storefront source code, build the libraries locally, and then make them available for installation.

# Prerequisites
Before starting any the procedures on this document, you must fulfill the follow prerequisites:
1) Install the appropriate versions of node.js and Angular CLI for the release you are building. **Current version of Braintree library works with Angular version 16.x.x.**
2) Install the ts-node TypeScript execution engine. To install ts-node, open a terminal window and enter the following command:
   
    ```npm install -g ts-node```
3) Install an npm-like registry software. In this guide we will use **Verdaccio**, which is a lightweight Node.js private proxy registry. To install Verdaccio, open a terminal window and enter the following command:

   ```npm install -g verdaccio```
4) Add user for Verdaccio 
 
   ```npm adduser --registry http://localhost:4873```.

   **Note**: Verdaccio uses port 4873 by default. You can configure the port in the Verdaccio configuration file
# Building and Serving the Braintree Spartacus Library Using a Local Registry
In the following procedure, Verdaccio is used in the steps involving registry software, but you can use any proxy registry software that is similar to npm.

**Note**: These steps assume that your proxy registry is already running in a terminal window.

1) Unzip pypl-bt_SPA.zip
2) Go to folder `braintree-spartacus-libs`
3) Build library ```npm install && ng build```
4) Go to compiled library folder:```braintree-spartacus-libs/dist```
   and push it to local repository:

   ```npm publish --registry=http://localhost:4873 --no-git-tag-version```
5) Add a dependency to the Braintree Spartacus library in your application's package.json file:
```"@braintree/spartacus": "1.0.0"```
6) Install Braintree Spartacus library to your Angular application:
```npm install```
After this step Braintree Spartacus library will be stored in ``node_modules`` directory of your Angular application
7) Import BraintreeStorefrontModule to the main module.

```ts
import {BraintreeStorefrontModule, defaultBraintreeCheckoutConfig} from '@braintree/spartacus';

@NgModule({
   declarations: [
      AppComponent
   ],
   imports: [
      BraintreeStorefrontModule.withConfig({
         braintreeCheckout: {
            allowGuestExpressCheckout: true, // change this property to FALSE if you want to disable express checkout for guest user
            isB2B: false // change this property to TRUE if you are using B2B commerce
         }
      })
   ]
```
8) Import styles to you application style scss file
```ts
@import '@spartacus/styles/index';
@import '@braintree/spartacus/styles/index';
```

9) Rebuild your application using: ``ng build``. Now Braintree Spartacus library is installed to angular application.


