解决报错:Not implemented: HTMLCanvasElement.prototype.getContext (xxx installing the canvas npm pack

这个是在js逆向中使用jsdom模拟浏览器环境,结果还是报错了: 

网上很多说法是安装canvas: npm install canvas,其实并不正确 

解决办法:加入以下代码:

window.HTMLCanvasElement.prototype.getContext = () => {

  // return whatever getContext has to return

};

问题解决: