Skip to content
This repository has been archived by the owner on Jun 8, 2022. It is now read-only.

Generating node_modules for node runtimes #26

Open
lorengordon opened this issue Sep 13, 2018 · 4 comments
Open

Generating node_modules for node runtimes #26

lorengordon opened this issue Sep 13, 2018 · 4 comments

Comments

@lorengordon
Copy link
Contributor

Any thoughts on running something like npm install --production to create the node_modules directory prior to zipping up a directory for node runtimes? Generally, the directory is added to a .gitignore, so the dependencies are not present unless installed first.

@lorengordon
Copy link
Contributor Author

One option could be to detect the node runtime, that the source_path is a directory, that there is a package.json file in that directory, and that there is no node_modules directory. Then automatically run npm install --production in that directory.

Another option would be to expose a new argument, vendor_cmd, which a user could use to run an arbitrary command in the source_path directory before creating the archive.

@raymondbutcher
Copy link
Contributor

Hi, as you know we were working on custom build commands. That's in v0.11.0 now and an example can be found at https://github.com/claranet/terraform-aws-lambda/tree/master/tests/build-command

If you come up with a good nodejs example, we can add it to the tests directory and think about pulling the functionality into build.py so it doesn't require a custom build script.

@rednap
Copy link
Contributor

rednap commented Jul 11, 2019

as this issue is still open, just wanted to point out that the above example works on node packages. just change pip install --progress-bar off -r requirements.txt -t . && to npm install && in build.sh

also, thank you for this example. hadn't seen it before and it was super helpful.

@raymondbutcher
Copy link
Contributor

Thanks for reporting that it works 👍

I've made another module terraform-aws-lambda-builder that supports nodejs and doesn't require nodejs or docker to be installed locally. I've only added support for nodejs8.10 so far because I needed to deploy a function using that runtime, but it should be very easy to make it work with nodejs 10 too.

mbklein pushed a commit to nulib/terraform-aws-lambda that referenced this issue Apr 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants