Tim-B / grunt-aws-lambda

A grunt plugin to assist in developing functions for AWS Lambda.
MIT License
247 stars 100 forks source link

node_modules missing from zip file #86

Closed yuvalselffer closed 8 years ago

yuvalselffer commented 8 years ago

running lambda_package task creates a zip in /dist that is missing the /node_modules folder.

i tried setting the permissions on the node_modules, in case that was the problem. but no, it still persists.

it started happening after i deleted the node_modules folder and npm installed again. i also tried to copy the project into a new folder and the same is still happening.

did anyone encounter this issue before?

yuvalselffer commented 8 years ago

i guess this is something specific to my installation.. maybe posting my grunt file will help:

var AWS = require('aws-sdk');
AWS.config.region = 'us-east-1';

var grunt = require('grunt');
grunt.loadNpmTasks('grunt-awe-lambda');

grunt.initConfig({
    lambda_invoke: {
        default: {
            options: {
                file_name: 'index.js'
            }
        }
    },
    lambda_deploy: {
        default: {
            arn: 'arn:aws:lambda:us-east-1:zzzz:function:xxxx',
            options: {
                enableVersioning: true,
                region: 'us-east-1'
            }
        }
    },
    lambda_package: {
        default: {
            include_time: false,
            include_files: ['node_modules']
        }
    }
});

grunt.registerTask('deploy', ['lambda_package', 'lambda_deploy'])
yuvalselffer commented 8 years ago

solved this by adding some dependencies as bundledDependencies.

old package.json:

{
  "name": "xxx",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "devDependencies": {
    "async": "^2.0.1",
    "aws-sdk": "^2.5.3",
    "gm": "^1.23.0",
    "grunt": "^1.0.1",
    "grunt-aws-lambda": "^0.13.0"
  }
}

new package.json:

{
  "name": "xxx",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "devDependencies": {
    "async": "^2.0.1",
    "aws-sdk": "^2.5.3",
    "gm": "^1.23.0",
    "grunt": "^1.0.1",
    "grunt-aws-lambda": "^0.13.0"
  },
  "bundledDependencies": [
    "async",
    "gm"
  ]
}