agutoli / serverless-layers

Serverless.js plugin implementing AWS Lambda Layers, reducing lambda size, warm-up, and deployment time.
MIT License
230 stars 54 forks source link

node_modules not included in layers #163

Open naveen-murali opened 8 months ago

naveen-murali commented 8 months ago

Issue Description: After upgrading to version v2.8.5 of serverless-layers, the plugin fails to include the node_modules directory in its generated layers.

Steps to Reproduce:

  1. Upgrade serverless-layers to v2.8.5.
  2. Deploy a serverless application that utilizes layers.
  3. Verify the contents of the deployed layers.

Expected Behavior: The layers should contain the node_modules directory, including all dependencies required by the specified packages.

Actual Behavior: Upon inspection of the deployed layers, we can see that the node_modules directory is missing.

Workaround: Reverting to version v2.7.0 of serverless-layers resolves the issue, as the node_modules directory is correctly included in the generated layers.

Environment:

Screenshot: example Here you can observe that the total layer size is much less than it should be.

sabotageivet123 commented 8 months ago

Same here. The latest version generates a layer without node_modules, it contains just package-lock.json file.

JoseFortunato commented 8 months ago

Same here. I downgrade version and its working fine...

rsi-mrobinson commented 8 months ago

Same here, downgraded to 2.7.0. I also saw an sdk error on the latest version when trying to run serverless deploy

... ○ Created layer package /path/to/Developer/packages/api/.serverless/layer.zip (0.2 MB)
... ○ Uploading layer package...
... ○ OK...
ServerlessLayers error:
    Action: Lambda:publishLayerVersion
    Params: {"Content":{"S3Bucket":"mybucket","S3Key":"serverless/blah/blah/layers/layer.zip"},"LayerName":"layername","Description":"created by serverless-layers plugin (123456789)","CompatibleRuntimes":["nodejs"],"CompatibleArchitectures":["x86_64","arm64"]}
AWS SDK error:
    Could not find API configuration lambda-2015-03-31
jeanoliveira92 commented 8 months ago

Im too. I have the same problem. I downgraded too to 2.7.0 and still showing error on deploy =(

... ○ Uploading layer package...
... ○ OK...
ServerlessLayers error:
Action: Lambda:publishLayerVersion
    Params: {"Content":{"S3Bucket":"serverless","S3Key":"serverless/service/dev/layers/altu-service-dev-nodejs-serverless.zip"},"LayerName":"altu-service-dev-nodejs-serverless","Description":"created by serverless-layers plugin (1170cc4a8683d81ff4c3125ba5f45457)","CompatibleRuntimes":["nodejs20.x"],"CompatibleArchitectures":["x86_64","arm64"]}
AWS SDK error:
    Could not find API configuration lambda-2015-03-31
error
Running "serverless" from node_modules

@agutoli help us please. The project stop to upload beacause this problem. Sorry and thanks ^^

Updated: @rsi-mrobinson i changed the "serverless-layers" from devDependencies to dependencies and set the version to "2.7", yes without the third number and worked to me! \O/

rajeevbbqq commented 8 months ago

If anyone is facing issues even after downgrading to 2.7.0 then cross-check package.json by

serverless-layers: 2.7.0 remove ^ from serverless layers if it is there!

OmarKhattab commented 8 months ago

Related to #166

fl-wxiao commented 6 months ago

I made localized modifications to the source code. This is not safe, but at least it will not prevent the normal deployment of the service.