Creating a standalone node package archive for a lambda from an npm workspace directory

Viewed 69

I have a monorepo using npm workspaces which, after installing, looks like this:

/
  package.json
  node_modules/
  packages/
    lambda/
      node_modules/
      package.json
      package-lock.json
      <source code>
    cdk-stacks/
      node_modules/
      package.json
      package-lock.json
      <source code>

I'm needing to create a .zip file which can be uploaded to AWS as a Lambda handler, created from the code in ./packages/lambda. However, some of the dependencies are hoisted to the top-level node_modules.

Is there a way, short of copying files to a new directory outside of the monorepo, to do an install such that all node_modules are installed at the root of a specific package so that a .zip archive isn't missing any dependencies?

0 Answers
Related