frinyvonnick / node-html-to-image

A Node.js module that generates images from HTML
https://www.npmjs.com/package/node-html-to-image
Apache License 2.0
823 stars 126 forks source link

UnhandledPromiseRejectionWarning: Error: Browser is not downloaded. Run "npm install" or "yarn install" #34

Closed udayraj21 closed 4 years ago

udayraj21 commented 4 years ago

I have installed this library in node js. I am trying to get an image from html but I get UnhandledPromiseRejectionWarning: Error: Browser is not downloaded. Run "npm install" or "yarn install" error always. OS: Ubuntu 18.04 LTS Node: v12.14.1 NPM: 6.14.5

Here is log:

(node:31583) UnhandledPromiseRejectionWarning: Error: Browser is not downloaded. Run "npm install" or "yarn install" at ChromeLauncher.launch (webpack:///./node_modules/puppeteer/lib/Launcher.js?:236:15) at module.exports (webpack:///./node_modules/node-html-to-image/src/index.js?:22:19) at eval (webpack:///./app/helpers/HtmlToImage.js?:12:19) (node:31583) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:31583) [DEP0018] 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.

frinyvonnick commented 4 years ago

Hi @udayraj21 👋

Thank you for sharing you issue. Could you provide me the code you used and tell me more about your environment please 🙏 ?

kuli00 commented 4 years ago

@frinyvonnick I have the same issue

const nodeHtmlToImage = require('node-html-to-image');

export default async (req, res) => {
  try {
    const image = await nodeHtmlToImage({
      html: '<html><body><div><img src="https://domain.com/some_image.png" /><img src="https://domain.com/some_image.png" /></div></body></html>'
    });
    res.writeHead(200, { 'Content-Type': 'image/png' });
    res.end(image, 'binary');
    return res;
  } catch (e) {
    console.log(e);
    return res.status(400).json({ error: e });
  }
};

env: serverless function in next.js For now I'm testing this on local env

frinyvonnick commented 4 years ago

Hi @kuli00, thank you for sharing your issue. Do you use yarn or npm? Which node version do you use?

kuli00 commented 4 years ago

yarn - 1.21.1 node - 12.14.1

kuli00 commented 4 years ago

@frinyvonnick any news?

aarshaw commented 4 years ago

also having this issue ^

frinyvonnick commented 4 years ago

In another issue a solution have been posted for Ubuntu. Does it help?

frinyvonnick commented 4 years ago

@aarshaw @kuli00 @udayraj21 Did you try the solution in my previous message ☝️ ?

frinyvonnick commented 4 years ago

I close this issue, feel free to reopen it if you have further information.