Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] "Error: ENOENT: no such file or directory, mkdir 'E:\\tmp\\.fonts'\n #344

Open
lapph opened this issue Mar 14, 2025 · 3 comments
Open
Labels
bug Something isn't working

Comments

@lapph
Copy link

lapph commented Mar 14, 2025

Environment

  • "@sparticuz/chromium": "^132.0.0",
  • "puppeteer-core": "^24.2.1",
  • Node.js Version: 20.18.3
  • Lambda / GCF Runtime: 20x

Expected Behavior

It can run on my local

Current Behavior

Can'n running on local. But run on production

Steps to Reproduce

Structure:
aws-lambda
/access
/.fonts
ipaexm.ttf
ipaexg.ttf

Error

"Error: ENOENT: no such file or directory, mkdir 'E:\tmp\.fonts'\n at mkdirSync (node:fs:1372:26)\n at Function.font"

protected async createReportPdf(contents: string): Promise<Buffer> {
    try {
      let opts = {};
      if (isProduction) {
        await chromium.font("/opt/fonts/ipaexg.ttf");
        await chromium.font("/opt/fonts/ipaexm.ttf");
        opts = {
          args: chromium.args,
          defaultViewport: chromium.defaultViewport,
          executablePath: await chromium.executablePath(),
          headless: true,
          ignoreHTTPSErrors: true
        };
      } else {
        await chromium.font("assets/.fonts/ipaexg.ttf");
        await chromium.font("assets/.fonts/ipaexm.ttf");
        opts = {
          args: ["--headless"],
          defaultViewport: chromium.defaultViewport,
          executablePath: process.env.CHROME_PATH || chrome,
          channel: "chrome",
          headless: true,
          ignoreHTTPSErrors: true
        };
      }
      const browser: any = await puppeteer.launch(opts);
      const page: any = await browser.newPage();
      await page.setContent(contents);
      const pdf: Buffer = await page.pdf({
        format: PDF_PAGE_SIZE,
        printBackground: true,
        landscape: false,
        timeout: 0
      });
      browser.close();
      return pdf;
    } catch (e) {
      throw e;
    }
  }

-->

Possible Solution

@lapph lapph added the bug Something isn't working label Mar 14, 2025
@lapph
Copy link
Author

lapph commented Mar 14, 2025

It still works on "@sparticuz/chromium" version: 111.0.0, but not on greater versions

@lapph
Copy link
Author

lapph commented Mar 17, 2025

Using the path font online but it's not working:
// await chromium.font("assets/.fonts/ipaexg.ttf");
// await chromium.font("assets/.fonts/ipaexm.ttf");
await chromium.font(
"https://raw.githack.com/googlei18n/noto-emoji/master/fonts/NotoColorEmoji.ttf"
);
opts = {
args: ["--headless"],
defaultViewport: chromium.defaultViewport,
executablePath: process.env.CHROME_PATH || chrome,
channel: "chrome",
headless: true,
ignoreHTTPSErrors: true
};

@lapph
Copy link
Author

lapph commented Mar 17, 2025

"error": "Error: ENOENT: no such file or directory, mkdir 'E:\tmp\.fonts'\n at mkdirSync (node:fs:1372:26)\n at Function.font

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant