Essayer d'utiliser node-vibrant dans le projet ng5. j'essaie donc d'importer le package npm avec
import Vibrant = require('node-vibrant');
//ou alors
importer Vibrant depuis 'node-vibrant' ;
//ou alors
importer * en tant que Vibrant depuis 'node-vibrant/src/vibrant' ;
//ou alors
import Vibrant = require('node-vibrant/src/vibrant')
sans succès .
j'essaye de l'utiliser comme ça
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 ici
})
@amirping , je pense que le problème est que la bibliothèque ne parvient pas à charger l'image. Dans #61, voir ce commit .
@amirping
J'ai réussi à l'utiliser comme ci-dessous-
const vibrant = require('node-vibrant');
En utilisant v 3.1.1
, pouvons-nous confirmer que l'utilisation de import Vibrant = require('node-vibrant')
fonctionne ?
@crutchcorn
J'ai essayé à la fois import Vibrant = require('node-vibrant')
et const Vibrant = require('node-vibrant')
Le premier donne #90. Ce dernier donne #85.
Merci d'avoir testé. je vais regarder de plus près cette semaine
Commentaire le plus utile
@crutchcorn
J'ai essayé à la fois
import Vibrant = require('node-vibrant')
etconst Vibrant = require('node-vibrant')
Le premier donne #90. Ce dernier donne #85.