sam build fail with "No such file or directory" for node build
See original GitHub issueDescription
When building with
sam build --template sam-template.yaml
the build fail due to non existent temporary folder
Steps to reproduce
run sam build --template sam-template.yaml
with js source in a scub package
Observed result
Running workflow ‘NodejsNpmBuilder’ Running NodejsNpmBuilder:NpmPack NODEJS packaging file:<project-dir>/authorizer to /tmp/tmpmn3v_qa7 executing NPM: [‘npm’, ‘pack’, ‘-q’, ‘file:<project-dir>/authorizer’] NODEJS packed to > backlinks-authorizer@1.0.0 prepare <project-dir>/authorizer
npm run build
backlinks-authorizer@1.0.0 build <project-dir>/authorizer tsc --outDir build
backlinks-authorizer-1.0.0.tgz NODEJS extracting to /tmp/tmpmn3v_qa7/unpacked NodejsNpmBuilder:NpmPack raised unhandled exception Traceback (most recent call last): File “/home/xxx/.local/lib/python3.6/site-packages/aws_lambda_builders/workflow.py”, line 248, in run action.execute() File “/home/xxx/.local/lib/python3.6/site-packages/aws_lambda_builders/workflows/nodejs_npm/actions.py”, line 67, in execute self.osutils.extract_tarfile(tarfile_path, self.artifacts_dir) File “/home/xxx/.local/lib/python3.6/site-packages/aws_lambda_builders/workflows/nodejs_npm/utils.py”, line 23, in extract_tarfile with tarfile.open(tarfile_path, ‘r:*’) as tar: File “/usr/lib/python3.6/tarfile.py”, line 1571, in open return func(name, “r”, fileobj, **kwargs) File “/usr/lib/python3.6/tarfile.py”, line 1636, in gzopen fileobj = gzip.GzipFile(name, mode + “b”, compresslevel, fileobj) File “/usr/lib/python3.6/gzip.py”, line 163, in init fileobj = self.myfileobj = builtins.open(filename, mode or ‘rb’) FileNotFoundError: [Errno 2] No such file or directory: ‘/tmp/tmpmn3v_qa7/> backlinks-authorizer@1.0.0 prepare <build-dir>/authorizer\n> npm run build\n\n\n> backlinks-authorizer@1.0.0 build /<build-dir>/authorizer\n> tsc --outDir build\n\nbacklinks-authorizer-1.0.0.tgz’
Build Failed
Expected result
The temp directory (and sub dirs) should be created for the script to continue
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: Ubuntu 18.04.3
sam --version
: SAM CLI, version 0.22.0
Add --debug flag to command you are running
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (7 by maintainers)
Ok, here’s a bit of background to help out. https://github.com/awslabs/aws-lambda-builders/blob/develop/aws_lambda_builders/workflows/nodejs_npm/DESIGN.md contains the design of the Node builder that’s run by
sam build
.@seriojaignat we run
npm pack
which I understand ignores files in your .gitignore by default, so you may want to add an .npmignore file that has a narrower scope and see if that includes the files you want built.@Cubid What version of node are you running? I’m doing some research and it does look like
prepack
can have issues withpack
depending on version (though I’m not a node expert myself so I’m researching in parallel here).Understood - we have some features in our backlog that should make this easier in general, but I’m looking in to what to recommend for this use case.