Using external library in Ionic - blue-button


#1

Hi guys,

This might be a very basic problem but I am new to Ionic so please bear with me.

So the problem is -

How can I use following npm library in ionic?

Tried this but no success - import blue_button from ‘blue-button’

It says -

[ts]
Could not find a declaration file for module ‘blue-button’. ‘Parser/node_modules/blue-button/index.js’ implicitly has an ‘any’ type.
Try npm install @types/blue-button if it exists or add a new declaration (.d.ts) file containing declare module 'blue-button';

But above steps also gives an error and does not help.

Any help would be appreciated.
Thanks.


#2

Try declare let bluebutton and see if that works.

Blue button can the name of the module.


#3

I fixed this by following below steps -

npm i @types/node

then add following lines in tsconfig.json file

“compilerOptions”: {
“types”: [ “node” ],
“typeRoots”: [ “node_modules/@types” ]
}
This fixed the issue for me.
If there is any better alternative then please suggest.

Thanks.