Open kevinreedy opened 9 years ago
Thanks for bringing this up.
I can imagine this will be a complicated to resolve if you're developing on an environment that doesn't match the Lambda environment (eg. developing on Windows and running on Lambda/Linux).
Perhaps you could manually build binaries then include them in the correct folder using something like the include_files option.
If you unzip the generated package and run npm build does it work?
I've been using a Docker container to do the build, so that it'll actually build correctly for lambda. As for running npm build .
in the root after unzipping the package, it doesn't do anything. But, if I cd node_modules/chef-api/node_modules/ursa && npm build .
, it will do the build of the native extensions for that nested requirement.
I was able to get around this using the include_files
option for now. It looks like that doesn't include recursively though, so I'm getting a bit verbose. https://github.com/kevinreedy/chef-asg-cleanup/blob/master/Gruntfile.js#L18-L29
@kevinreedy can you share your docker file which simulates the lambda environment - at the moment I use a ec2 instance and this would make it much easier to build the node modules with binary parts (iconv, fibers) - thanks
@aheissenberger take a look at https://github.com/kevinreedy/chef-asg-cleanup for how I'm successfully building now, specifically https://github.com/kevinreedy/chef-asg-cleanup/blob/master/Dockerfile and https://github.com/kevinreedy/chef-asg-cleanup/blob/master/docker-compose.yml
@kevinreedy @aheissenberger @Tim-B,
I've made a library that may help with these kinds of issues: https://github.com/FreeAllMedia/akiro
I'm attempting use grunt-aws-lambda for a project (https://github.com/kevinreedy/chef-asg-cleanup) that uses https://github.com/normanjoyner/chef-api. One of its dependencies is https://github.com/quartzjer/ursa, which has native extensions. When I run an
npm install
, the extensions are built! When I rungrunt lambda_package
, they are not. Steps to reproduce below:I imagine there's an option that is needed to pass into
npm.commands.install
(https://github.com/Tim-B/grunt-aws-lambda/blob/master/tasks/lambda_package.js#L59-L66) to ensure thatnode-gyp
gets called, but it's not obvious from looking at npm's code. Any thoughts to push me in the right direction? Thanks!