Description:
sam build fails on unmodified example
Steps to reproduce:
$ sam init
with the following choices:
Template: 1 - AWS Quick Start Templates
Quick Start template: 1 - Hello World Example
Runtime: 12 - nodejs18.x
Package type: 1 - Zip
Template 2 - Hello World Example TypeScript
X-Ray tracing, CloudWatch: no
$ cd sam-app
$ sam build
Note: npm install; npm run test
succeeds without error
Observed result:
$ sam build --debug
2022-12-29 15:52:47,119 | Config file location: /tmp/sam-app/samconfig.toml
2022-12-29 15:52:47,120 | Config file '/tmp/sam-app/samconfig.toml' does not exist
2022-12-29 15:52:47,125 | Using SAM Template at /tmp/sam-app/template.yaml
2022-12-29 15:52:47,174 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2022-12-29 15:52:47,175 | Using config file: samconfig.toml, config environment: default
2022-12-29 15:52:47,175 | Expand command line arguments to:
2022-12-29 15:52:47,175 | --template_file=/tmp/sam-app/template.yaml --build_dir=.aws-sam/build --cache_dir=.aws-sam/cache
2022-12-29 15:52:47,319 | 'build' command is called
2022-12-29 15:52:47,325 | No Parameters detected in the template
2022-12-29 15:52:47,338 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id
2022-12-29 15:52:47,338 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id
2022-12-29 15:52:47,339 | 0 stacks found in the template
2022-12-29 15:52:47,339 | No Parameters detected in the template
2022-12-29 15:52:47,352 | There is no customer defined id or cdk path defined for resource HelloWorldFunction, so we will use the resource logical id as the resource id
2022-12-29 15:52:47,352 | There is no customer defined id or cdk path defined for resource ServerlessRestApi, so we will use the resource logical id as the resource id
2022-12-29 15:52:47,353 | 2 resources found in the stack
2022-12-29 15:52:47,353 | Found Serverless function with name='HelloWorldFunction' and CodeUri='hello-world/'
2022-12-29 15:52:47,353 | --base-dir is not presented, adjusting uri hello-world/ relative to /tmp/sam-app/template.yaml
2022-12-29 15:52:47,359 | 2 resources found in the stack
2022-12-29 15:52:47,359 | Found Serverless function with name='HelloWorldFunction' and CodeUri='hello-world/'
2022-12-29 15:52:47,359 | Found Serverless function with name='HelloWorldFunction' and CodeUri='hello-world/'
2022-12-29 15:52:47,359 | --base-dir is not presented, adjusting uri hello-world/ relative to /tmp/sam-app/template.yaml
2022-12-29 15:52:47,360 | Instantiating build definitions
2022-12-29 15:52:47,360 | No previous build graph found, generating new one
2022-12-29 15:52:47,360 | Unique function build definition found, adding as new (Function Build Definition: BuildDefinition(nodejs18.x, /tmp/sam-app/hello-world, Zip, , 1cf07abd-4df9-47d3-a970-711f7864556a, {'BuildMethod': 'esbuild', 'BuildProperties': {'Minify': True, 'Target': 'es2020', 'Sourcemap': True, 'EntryPoints': ['app.ts']}}, {}, x86_64, []), Function: Function(function_id='HelloWorldFunction', name='HelloWorldFunction', functionname='HelloWorldFunction', runtime='nodejs18.x', memory=None, timeout=3, handler='app.lambdaHandler', imageuri=None, packagetype='Zip', imageconfig=None, codeuri='/tmp/sam-app/hello-world', environment=None, rolearn=None, layers=[], events={'HelloWorld': {'Type': 'Api', 'Properties': {'Path': '/hello', 'Method': 'get', 'RestApiId': 'ServerlessRestApi'}}}, metadata={'BuildMethod': 'esbuild', 'BuildProperties': {'Minify': True, 'Target': 'es2020', 'Sourcemap': True, 'EntryPoints': ['app.ts']}, 'SamResourceId': 'HelloWorldFunction'}, inlinecode=None, codesign_config_arn=None, architectures=['x86_64'], function_url_config=None, stack_path=''))
2022-12-29 15:52:47,361 | Building codeuri: /tmp/sam-app/hello-world runtime: nodejs18.x metadata: {'BuildMethod': 'esbuild', 'BuildProperties': {'Minify': True, 'Target': 'es2020', 'Sourcemap': True, 'EntryPoints': ['app.ts']}} architecture: x86_64 functions: HelloWorldFunction
2022-12-29 15:52:47,361 | Building to following folder /tmp/sam-app/.aws-sam/build/HelloWorldFunction
2022-12-29 15:52:47,362 | Loading workflow module 'aws_lambda_builders.workflows'
2022-12-29 15:52:47,364 | Registering workflow 'PythonPipBuilder' with capability 'Capability(language='python', dependency_manager='pip', application_framework=None)'
2022-12-29 15:52:47,364 | Registering workflow 'NodejsNpmBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm', application_framework=None)'
2022-12-29 15:52:47,365 | Registering workflow 'RubyBundlerBuilder' with capability 'Capability(language='ruby', dependency_manager='bundler', application_framework=None)'
2022-12-29 15:52:47,366 | Registering workflow 'GoModulesBuilder' with capability 'Capability(language='go', dependency_manager='modules', application_framework=None)'
2022-12-29 15:52:47,367 | Registering workflow 'JavaGradleWorkflow' with capability 'Capability(language='java', dependency_manager='gradle', application_framework=None)'
2022-12-29 15:52:47,368 | Registering workflow 'JavaMavenWorkflow' with capability 'Capability(language='java', dependency_manager='maven', application_framework=None)'
2022-12-29 15:52:47,369 | Registering workflow 'DotnetCliPackageBuilder' with capability 'Capability(language='dotnet', dependency_manager='cli-package', application_framework=None)'
2022-12-29 15:52:47,370 | Registering workflow 'CustomMakeBuilder' with capability 'Capability(language='provided', dependency_manager=None, application_framework=None)'
2022-12-29 15:52:47,371 | Registering workflow 'NodejsNpmEsbuildBuilder' with capability 'Capability(language='nodejs', dependency_manager='npm-esbuild', application_framework=None)'
2022-12-29 15:52:47,371 | Found workflow 'NodejsNpmEsbuildBuilder' to support capabilities 'Capability(language='nodejs', dependency_manager='npm-esbuild', application_framework=None)'
2022-12-29 15:52:47,372 | executing NPM: ['npm', 'bin']
2022-12-29 15:52:47,698 | Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
2022-12-29 15:52:47,699 | Unable to find Click Context for getting session_id.
2022-12-29 15:52:47,699 | Sending Telemetry: {'metrics': [{'commandRun': {'requestId': 'dfd84683-08ab-4079-8242-6cc50f9d5044', 'installationId': 'd0401db6-4ad8-461c-aeb4-07cce42e8d89', 'sessionId': 'f8cbf88d-6bbf-4f58-a3bd-2b258a7fe252', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.7.10', 'samcliVersion': '1.67.0', 'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam build', 'metricSpecificAttributes': {'projectType': 'CFN', 'gitOrigin': None, 'projectName': '593ab2ca51e925b9f6c2f258bc55ed5926cf6d2c78239a685d65907e4ec7edd3', 'initialCommit': None}, 'duration': 523, 'exitReason': 'NpmExecutionError', 'exitCode': 255}}]}
2022-12-29 15:52:47,700 | Sending Telemetry: {'metrics': [{'events': {'requestId': 'b159d1fd-f009-4e56-bb4a-724ba258ac90', 'installationId': 'd0401db6-4ad8-461c-aeb4-07cce42e8d89', 'sessionId': 'f8cbf88d-6bbf-4f58-a3bd-2b258a7fe252', 'executionEnvironment': 'CLI', 'ci': False, 'pyversion': '3.7.10', 'samcliVersion': '1.67.0', 'metricSpecificAttributes': {'events': [{'event_name': 'BuildWorkflowUsed', 'event_value': 'nodejs-npm-esbuild', 'thread_id': 139922124578816, 'time_stamp': '2022-12-29 20:52:47.361'}]}}}]}
2022-12-29 15:52:48,485 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Traceback (most recent call last):
File "samcli/__main__.py", line 12, in <module>
2022-12-29 15:52:48,486 | HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
File "click/core.py", line 1130, in __call__
File "click/core.py", line 1055, in main
File "click/core.py", line 1657, in invoke
File "click/core.py", line 1404, in invoke
File "click/core.py", line 760, in invoke
File "click/decorators.py", line 84, in new_func
File "click/core.py", line 760, in invoke
File "samcli/lib/telemetry/metric.py", line 194, in wrapped
File "samcli/lib/telemetry/metric.py", line 140, in wrapped
File "samcli/lib/utils/version_checker.py", line 41, in wrapped
File "samcli/cli/main.py", line 86, in wrapper
File "samcli/commands/build/command.py", line 206, in cli
File "samcli/commands/build/command.py", line 276, in do_cli
File "samcli/commands/build/build_context.py", line 256, in run
File "samcli/lib/build/app_builder.py", line 210, in build
File "samcli/lib/build/build_strategy.py", line 80, in build
File "samcli/lib/build/build_strategy.py", line 90, in _build_functions
File "samcli/lib/build/build_strategy.py", line 174, in build_single_function_definition
File "samcli/lib/build/app_builder.py", line 705, in _build_function
File "samcli/lib/build/app_builder.py", line 859, in _build_function_in_process
File "aws_lambda_builders/builder.py", line 161, in build
File "aws_lambda_builders/workflows/nodejs_npm_esbuild/workflow.py", line 56, in __init__
File "aws_lambda_builders/workflows/nodejs_npm_esbuild/workflow.py", line 218, in _get_esbuild_subprocess
File "aws_lambda_builders/workflows/nodejs_npm/npm.py", line 85, in run
aws_lambda_builders.workflows.nodejs_npm.npm.NpmExecutionError: NPM Failed:
[444677] Failed to execute script '__main__' due to unhandled exception!
Expected result:
I would expect "Build Succeeded" much like what happens when I use the Javascript Hello World Example
like so:
Building codeuri: /tmp/sam-app-js/hello-world runtime: nodejs18.x metadata: {} architecture: x86_64 functions: HelloWorldFunction
Running NodejsNpmBuilder:NpmPack
Running NodejsNpmBuilder:CopyNpmrcAndLockfile
Running NodejsNpmBuilder:CopySource
Running NodejsNpmBuilder:NpmInstall
Running NodejsNpmBuilder:CleanUpNpmrc
Running NodejsNpmBuilder:LockfileCleanUp
Build Succeeded
Built Artifacts : .aws-sam/build
Built Template : .aws-sam/build/template.yaml
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
$ cat /etc/issue
Ubuntu 22.04.1 LTS
$ aws --version
aws-cli/2.9.11 Python/3.9.11 Linux/5.15.0-56-generic exe/x86_64.ubuntu.22 prompt/off
$ sam --version
SAM CLI, version 1.67.0
region = us-east-1
$ node --version
v18.12.1
$ npm --version
9.1.3
stage/needs-investigation maintainer/need-followup