Search code examples
node.jslambdaaws-lambdaaws-sdk-nodejssam

How do i avoid SAM build installing devDependencies


my current folder structure is as attached file. it's a nodejs application and we use SAM to deploy in AWS. each folder is a separate lambda function and it has devDependencies in package.json which really does not need to be bundled during SAM build. but as I understand the default behaviour of "sam build" is to install devDependencies as well. In my case this devDependcies are in the private repository so i need .npmrc file in each folder to make "sam build" command work. but i really dont need these devDependencies as we use layers and all dependencies are stored in layers in my serverless application. How do i make aws build ignore my dev dependencies? [1]: https://i.sstatic.net/91qd2.png


Solution

  • What version of SAM are you using? It used to be a bug with esbuild in older version of SAM, but should be fixed as of 1.56.0: https://github.com/aws/aws-sam-cli/issues/4040