claudiajs / claudia

Deploy Node.js projects to AWS Lambda and API Gateway easily

Home Page:https://claudiajs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

claudia pack does not work with npm workspaces

mdesousa opened this issue · comments

  • Expected behaviour: I am using npm 7 workspaces. When I run claudia pack with a module that depends on workspaces, I expect those workspaces to be included in the node_modules folder.

  • What actually happens: workspaces are missing in the zip file created by claudiajs. When the lambda is deployed to AWS, you get errors: "Runtime.ImportModuleError: Cannot find module 'xyz'"

  • Steps to reproduce the problem: create a project that uses npm workspaces (see https://docs.npmjs.com/cli/v7/using-npm/workspaces). Create a "common" module and a "lambda" module that depends on "common". List them as workspaces in the root package.json. Make sure that "lambda" invokes a function exported from "common". Use "claudia pack" to zip and deploy the lambda function.

  • Workaround: if you explicitly declare "common" in the dependencies section of lambda/package.json then everything works as expected. However, this eliminates part of the benefits of npm workspaces where these dependencies are not required.