question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

sam build fail with "No such file or directory" for node build

See original GitHub issue

Description

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)

  1. OS: Ubuntu 18.04.3
  2. sam --version: SAM CLI, version 0.22.0

Add --debug flag to command you are running

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
awood45commented, Oct 2, 2019

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 with pack depending on version (though I’m not a node expert myself so I’m researching in parallel here).

1reaction
awood45commented, Oct 2, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

sam build fail with "No such file or directory" for node build
Description When building with sam build --template sam-template.yaml the build fail due to non existent temporary folder Steps to reproduce ...
Read more >
Build Failed Error: NodejsNpmBuilder:NpmPack - NPM ...
Try building this in a container. Use sam build -u. This worked for me, but I am not sure why it wouldn't build...
Read more >
sam build - AWS Serverless Application Model
The sam build command processes your AWS SAM template file, application code, and any applicable language-specific files and dependencies.
Read more >
Using "sam build" - Build includes non required folders
How can you force 'sam build' commands to not include sub directories such as /node_modules and __tests__. These get added to each function...
Read more >
Tutorial: Deploying a Hello World application
In this guide, you download, build, and deploy a sample Hello World application using Amazon SAM. ... Amazon SAM CLI error: "no such...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found