rsmbl / Resemble.js

Image analysis and comparison

Home Page:http://rsmbl.github.io/Resemble.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

node issue

stephanfriedrich opened this issue · comments

commented

Hi thx for these tool,
i try to write an simple node-server example, but got an node issue on linux system, maybe someone could help.

Cant find any documentation, how to use Resemble.js.

node-version: v8.9.4

ISSUE

Unhandled promise rejection (rejection id: 2): Error: Cannot find module 'canvas-prebuilt'
(node:11924) [DEP0013] DeprecationWarning: Calling an asynchronous function without callback is deprecated.
(node:11924) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: Invalid ignore: nothing

CODE

const compareImages = require('resemblejs/compareImages');
const fs = require("fs");
const Canvas = require("canvas");

async function getDiff(){

  const data = await compareImages(
    await fs.readFileSync('./image1.png'),
    await fs.readFileSync('./image2.png'),
  );

 const buffer = data.getBuffer();

 console.log(data.isSameDimensions, buffer.length);
}

getDiff();

similar issue here:

(node:32005) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: The module '.../node_modules/canvas-prebuilt/canvas/build/Release/canvas.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 48. This version of Node.js requires
NODE_MODULE_VERSION 51. Please try re-compiling or re-installing
the module (for instance, using npm rebuild ornpm install).
(node:32005) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

although, it finds canvas-prebuilt / canvas.node. but it has an issue with node versions. I switched to nearly every possible version I got from nvm and did reinstall... nothing helped!

I am not sure if this helps but since I have had similar problems it may works for you @stephanfriedrich .

  1. update npm and node
  2. delete your node_modules folder
  3. force clear npm cache
  4. fresh npm install

Closing ticket, assuming it's a Node build issue