Mengatasi error pada jsdom

Saata menjalankan node-canvas versi terbaru dijumpai error seperti ini

Error: Cannot find module '../build/Release/canvas.node'

Edit pada ./node_moduls/jsdom/lib/jsdom/browser/not-implemented.js

// if (canvasInstalled) {
//   const Canvas = require("canvas");
//   if (typeof Canvas.createCanvas === "function") {
//     // In browserify, the require will succeed but return an empty object
//     exports.Canvas = Canvas;
//   }
// }

Edit pada ./node_moduls/jsdom/lib/jsdom/utils.js

"use strict";

module.exports = function (nameForErrorMessage, window) {
  if (!window) {
    // Do nothing for window-less documents.
    return;
  }

  // const error = new Error(`Not implemented: ${nameForErrorMessage}`);
  // error.type = "not implemented";

  // window._virtualConsole.emit("jsdomError", error);
};

Posting Komentar

Lebih baru Lebih lama