Trying to use node-vibrant in ng5 project . so i try to import the npm package with
import Vibrant = require('node-vibrant');
//or
import Vibrant from 'node-vibrant' ;
//or
import * as Vibrant from 'node-vibrant/src/vibrant';
//or
import Vibrant = require('node-vibrant/src/vibrant')
without success .
the i try to use it like that
declare var Vibrant :any;
Vibrant.from('this.toPlayRadio.pic').getPalette(function(err, palette) {
console.log(palette);
});
but it return an error when use it
TypeError: this._canvas is undefined
Stack trace:
TypeError: this._canvas is undefined
BroswerImage.prototype.remove@http://localhost:8080/node_modules/node-vibrant/dist/vibrant.js:12676:9
Vibrant.prototype.getPalette/<@http://localhost:8080/node_modules/node-vibrant/dist/vibrant.js:7103:43
finallyHandler@http://localhost:8080/node_modules/node-vibrant/dist/vibrant.js:2593:15
tryCatcher@http://localhost:8080/node_modules/node-vibrant/dist/vibrant.js:5910:16
[22]_settlePromiseFromHandler@http://localhost:8080
...
and this is my tsconfig.json file
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"noStrictGenericChecks": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true
}
and i use
"typescript": "^2.6.2",
so i am wondering how to use node-vibrant with ng5 , and how to correctly import it in ts class
import('node-vibrant').then((vibrant) => {
//code here
})
@amirping, I think the issue is that the library is failing to load the image. In #61, see this commit.
@amirping
I have managed to use it as below-
const vibrant = require('node-vibrant');
Using v3.1.1
, can we confirm that using import Vibrant = require('node-vibrant')
works?
@crutchcorn
Tried both import Vibrant = require('node-vibrant')
and const Vibrant = require('node-vibrant')
The former gives #90. The latter gives #85.
Thanks for testing. I'll take a closer look this week
Most helpful comment
@crutchcorn
Tried both
import Vibrant = require('node-vibrant')
andconst Vibrant = require('node-vibrant')
The former gives #90. The latter gives #85.