# Angular and Phaser

**URL:** <https://phaser.discourse.group/t/angular-and-phaser/534>\
**Category:** Phaser 3\
**Created:** [December 31, 2018, 12:57am UTC](https://phaser.discourse.group/t/angular-and-phaser/534 "2018-12-31T00:57:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LokiyoBazinga](https://avatars.discourse-cdn.com/v4/letter/l/3bc359/32.png) [@LokiyoBazinga](https://phaser.discourse.group/u/LokiyoBazinga)\
**Post date:** [December 31, 2018, 12:57am UTC](https://phaser.discourse.group/t/angular-and-phaser/534/1 "2018-12-31T00:57:04Z")

</div>

Hello everybody

I am new using Phaser, I want to integrate Phaser 3 in my application of Angular 6, within a component but I did not find the way to do it, download pharse from npm, but I am lost, someone could tell me where I can see more information about it or get oriented a little, I would appreciate it.

---

<div class="post-metadata">

**Author:** ![alb](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/alb/32/311_2.png) [@alb](https://phaser.discourse.group/u/alb)\
**Post date:** [December 31, 2018, 4:33am UTC](https://phaser.discourse.group/t/angular-and-phaser/534/2 "2018-12-31T04:33:30Z")

</div>

I struggled with this and eventually got it working. I’m not an expert though, so there may be better ways. This is what I did:

1. Added the npm module.

2. Copied the phaser.d.ts types file into my src folder.

3. At the top of phaser.d.ts, add these lines:

4. Added “node\_modules/phaser/dist/phaser.min.js” to the scripts array in angular.json.

5. In the ngOnInit method of my angular component, create a Phaser Game object.

6. Use phaser classes using the Phaser namespace e.g

The rest is the same as usual.

Hope that helps.

Edit: You may also need to add the following line to tsconfig.app.json

```
"inclue": ["*.d.ts"],
```

---

<div class="post-metadata">

**Author:** ![LokiyoBazinga](https://avatars.discourse-cdn.com/v4/letter/l/3bc359/32.png) [@LokiyoBazinga](https://phaser.discourse.group/u/LokiyoBazinga)\
**Post date:** [January 1, 2019, 1:44am UTC](https://phaser.discourse.group/t/angular-and-phaser/534/3 "2019-01-01T01:44:02Z")

</div>

Thanks, but since you imported the file phaser.d.ts to your component ?, it gives me an error, it says that this file is not a module and I am trying to import it in this way:

import \* as Pasher from ‘…/…/…/phaser’;

ERROR:  
File ‘c:/ … /src/phaser.d.ts’ is not a module.

---

<div class="post-metadata">

**Author:** ![alb](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/alb/32/311_2.png) [@alb](https://phaser.discourse.group/u/alb)\
**Post date:** [January 1, 2019, 2:27am UTC](https://phaser.discourse.group/t/angular-and-phaser/534/4 "2019-01-01T02:27:37Z")

</div>

I haven’t used import statements anywhere in my code. I do remember it being tricky to get working.

Try using the Phaser classes without importing anything.

If that doesn’t work, try replacing the import statement with

```
declare var Phaser;

```

I’ve also just tested my app without the include array in tsconfig.app.json. It seems to work fine without.

---

<div class="post-metadata">

**Author:** ![jbrecht](https://avatars.discourse-cdn.com/v4/letter/j/b5ac83/32.png) [@jbrecht](https://phaser.discourse.group/u/jbrecht)\
**Post date:** [January 21, 2019, 10:07pm UTC](https://phaser.discourse.group/t/angular-and-phaser/534/5 "2019-01-21T22:07:06Z")

</div>

Try using this starter as an example: [https://github.com/TristanBonsor/phangular](https://github.com/TristanBonsor/phangular)
