'Where is the node_modules folder placed in AWS Lambda

I uploaded a folder to Lambda with these contents:

  • main.js
  • node_modules

The code in main.js is executed, but it fails when I try to execute something inside the node_modules folder because it cannot find the file (ENOENT). It works locally.

This is what I've tried to locate the node_modules folder:

  • /var/task/node_modules
  • /var/runtime/node_modules
  • ./node_modules

This is the command I'm trying to execute from main.js:

    const { stdout, stderr } = await execa('./node_modules/.bin/prisma', ['migrate', 'deploy'])

Note: It is worth pointing out that I cannot just execute the command directly.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source