11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
https://www.11ty.dev/
MIT License
17.18k stars 494 forks source link

ENOENT: no such file or directory, mkdir '.cache' #3006

Closed raffaellarinaldi closed 1 year ago

raffaellarinaldi commented 1 year ago

Operating system

Ubuntu

Eleventy

2.0.1

Describe the bug

Hi, I am building a site with Eleventy with serveless plugin to render dynamic data. Works locally but when deploying to Netlify I see this error

Runtime.UnhandledPromiseRejection: Error: ENOENT: no such file or directory, mkdir '.cache'
    at process.<anonymous> (file:///var/runtime/index.mjs:1186:17)
    at process.emit (node:events:513:28)
    at emit (node:internal/process/promises:149:20)
    at processPromiseRejections (node:internal/process/promises:283:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:96:32)

Asked Netlify for support and they replied that .cache is not a writable directory in AWS Lambda - data can be written to /tmp. And suggested to file an issue here.

My code for serveless plugin (mostly copied from documentation)

// Serverless eleventyConfig.addPlugin(EleventyServerlessBundlerPlugin, { name: 'onrequest', functionsDir: './netlify/functions/', copy: [ { from: '.cache', to: 'cache' } ] });

Does anyone know how to fix this? Thanks

Reproduction steps

Expected behavior

Reproduction URL

Screenshots

No response

raffaellarinaldi commented 1 year ago

Ok I fixed it by adding directory: "/tmp/.cache/" to eleventy fetch.