I have a website that uses Netlify functions with Eleventy serverless.
The site has been working fine for six months but now I am getting the following error:
Error - Cannot find module '/var/task/netlify/functions/serverless/eleventy-serverless-map.json' Require stack: - /var/task/node_modules/@11ty/eleventy/src/Serverless.js - /var/task/node_modules/@11ty/eleventy/src/Eleventy.js - /var/task/netlify/functions/serverless/index.js - /var/task/serverless.js - /var/runtime/index.mjs
The serverless functions work as expected locally when I use the netlify-cli command netlify dev.
Any help gratefully received!
This is curious.
I found that if I deploy using netlify deploy --prod, then the deployed serverless functions work as expected.
If however I trigger a deploy from the Netlify UI, then the I see the ‘Cannot find module’ error above.
I’ve just confirmed with another project that this error only appears when a deploy is triggered via the Netlify UI or by a push to the git repo. When running netlify deploy locally everything works as expected.
I really need to understand what is causing this as we are working on a large project that will be deployed on Netlify in November and I need to make sure we can avoid the same issue.
Okay, thanks to this thread, I found the answer, which I will repeat here for any other poor Eleventy Serverless users encountering this issue. It seems this was caused by a change at the Netlify side.
Add the following to your netlify.toml:
node_bundler = "zisi"