serverless / serverless/serverless

Missing node modules while using deploying using serverless package and deploy command

Open
#11,928 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

question
Dominant language
JavaScript
Stars
46.9k
Forks
5.7k
Avg merge
10h 7m
Merged PRs (30d)
57

Description

Are you certain it's a bug?
  • Yes, it looks like a bug
Is the issue caused by a plugin?
  • It is not a plugin issue
Are you using the latest v3 release?
  • Yes, I'm using the latest v3 release
Is there an existing issue for this?
  • I have searched existing issues, it hasn't been reported yet
Issue description

We are deploying multiple lambda functions using a single serverless.yml file. Previously, when we inspected the pipeline artifacts, we found that all the required node_modules were installed in each lambda function's zip file. However, in recent pipeline runs, some of the lambda function zip files did not contain all the necessary node_modules.

Serverless version - tried using 3.x version as well 2.x
Node version - 14.15.4

Service configuration (serverless.yml) content
"N/A"
Command name and used flags

serverless package --stage --region --package

Command output
"errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module 'async'\nRequire stack:\n- /var/task/lambda/tools/index.js
Environment information
2.32.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the reported serverless package command and inspect the generated Lambda zip files, especially the artifact for lambda/tools/index.js. Compare the included node_modules with the runtime error for the missing async module. Done means each packaged function contains its required dependencies and the deployment no longer raises ImportModuleError.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, javascript, node.js
Domain
backend, build-system, cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.