How to add 3rd party JS (p5.js, phaser, mo.js)?


#1

Hello Ionic community!

Im new to ionic and need a little help.

I have implemented things like chart.js with the tutorial from https://www.joshmorony.com/adding-responsive-charts-graphs-to-ionic-2-applications/, and I really liked the out come.

BUT

I tried to do the same thing with p5.js from processing https://p5js.org/ and could not get it to work…

I have to display data for class on Data Visualization and want to use IONIC with mo.js, p5.js, or phaser.js to display this data.

Can anyone please help me find an answer to this?


#2

Were you able to find a fix for this?


#3

Facing this problem too. Don’t know how to require third party lib into ionic.
Npm install, import it in component.ts just doesn’t work.


#4

Hello,

as long you didn’t show code and nobody knows what you want to implement, you will never get a satisfing answer.

Best regards, anna-liebt


#5

Google is a great starting point


#6

@RCcola
@JeffreyChen

See, the moment.js docs for an example of how to include third-party JavaScript: https://momentjs.com/docs/#/use-it/typescript/


#7

This works. But I want to use npm for better management.
However, I had no luck fixing the typing error.

import { Component } from "@angular/core";
import { IonicPage, NavController, NavParams } from "ionic-angular";

import p5 from 'p5';  -> show the error below
// [ts] File '/Users/xxx/dev/birthcard/ionic-p5/node_modules/p5/lib/p5.d.ts' is not a module.

@IonicPage()
...