'not enough memory' Node error when trying to deploy

I’m trying to deploy a new Python 3.6 project to AWS Lambda but I"m unable to do so because of the following error:

Serverless: Zipping required Python packages...
Serverless: Packaging service...
Serverless: Excluding development dependencies...

  Error --------------------------------------------------

  ENOMEM: not enough memory, open '/c/ws/my-project/node_modules/lodash/stubObject.js'

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Stack Trace --------------------------------------------

Error: ENOMEM: not enough memory, open '/c/ws/my-project/node_modules/lodash/stubObject.js'
    at Package.getFileContent (/usr/lib/node_modules/serverless/lib/plugins/package/lib/zipService.js:116:15)
    at Package.getFileContentAndStat (/usr/lib/node_modules/serverless/lib/plugins/package/lib/zipService.js:105:12)
    at Array.map (<anonymous>)
    at WriteStream.output.on (/usr/lib/node_modules/serverless/lib/plugins/package/lib/zipService.js:83:29)
    at emitOne (events.js:116:13)
    at WriteStream.emit (events.js:211:7)
    at /usr/lib/node_modules/serverless/node_modules/graceful-fs/graceful-fs.js:214:14
    at /usr/lib/node_modules/serverless/node_modules/graceful-fs/graceful-fs.js:241:16
    at FSReqWrap.oncomplete (fs.js:135:15)

I understand there’s a limit to the size of Lambda packages (250MB) and my project directory is pretty fat clocking in at about 270MB. However, I get this error even when just trying to package the project.

I’m using the serverless-python-requirements plugin and I’m dockerizing my project as well.

For completion’s sake this is my serverless.yml:

service: my-project

provider:
  name: aws
  runtime: python3.6
  region: us-west-2

functions:
  main:
    handler: handler.main
    events:
      - http:
          path: /
          method: post

plugins:
  - serverless-python-requirements

custom:
  pythonRequirements:
    dockerizePip: non-linux
    zip: true

Anyone have any idea what might happening?

UPDATE:

Deleting arbitrary files to decrease the size of the project allowed me to successfully run the package command (creating a useless, non-functional package). Looking up the project size limit I found out it’s actually 50MB which is far too small for what I need so there’s probably some failsafe in the base AWS Lambda docker image that’s being used to build the package that prevents it from making packages that are too large.

Hey, DUMBASS self. If you get this error again it’s because you’re trying to deploy from your Vagrant box when you SHOULD be using your Ubuntu subystem. You need to make sure you’re using Pip 9.0.1!

1 Like

I’m encountering same issue with you, can you explain to me why not to use vagrant box? Do I need to install an ubuntu Subsystem in Window 10?

I assume you can use a Vagrant box you may just need to give it more RAM