Skip to content

Docs: Node 18.x Error for SAM example #1281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dilippatidar123 opened this issue Feb 8, 2023 · 3 comments
Closed

Docs: Node 18.x Error for SAM example #1281

dilippatidar123 opened this issue Feb 8, 2023 · 3 comments
Labels
documentation Improvements or additions to documentation duplicate This issue is a duplicate of an existing one rejected This is something we will not be working on. At least, not in the measurable future

Comments

@dilippatidar123
Copy link

dilippatidar123 commented Feb 8, 2023

Expected Behaviour

SAM Example should build successfully with node 18.x version.

Current Behaviour

sam build

Building codeuri: /codebuild/output/src099275065/src/Middy-Crud runtime: nodejs18.x metadata: {'BuildMethod': 'esbuild', 'BuildProperties': {'Minify': True, 'Target': 'ES2020', 'Sourcemap': True, 'EntryPoints': ['src/GetAllItems/get-all-items.ts']}} architecture: x86_64 functions: GetAllItems
Build Failed
Error: 'nodejs18.x' runtime is not supported

Code snippet

Globals:
  Function:
    Runtime: nodejs18.x
    Architectures:
      - x86_64
    MemorySize: 128
    Timeout: 100
Resources:
  GetAllItems:
      Type: AWS::Serverless::Function
      Properties:
        Handler: src/GetAllItems/get-all-items.handler
        Description: A simple example includes a HTTP get method to get all items from a DynamoDB table.
        Policies:
          # Give Create/Read/Update/Delete Permissions to the SampleTable
          - DynamoDBReadPolicy:
              TableName: !Ref SampleTable
        Tracing: Active
        Environment:
          Variables:
            # Make table name accessible as environment variable from function code during execution
            NODE_OPTIONS: '--enable-source-maps' # see https://docs.aws.amazon.com/lambda/latest/dg/typescript-exceptions.html
            AWS_NODEJS_CONNECTION_REUSE_ENABLED: 1 # see https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/node-reusing-connections.html
            SAMPLE_TABLE: !Ref SampleTable
            POWERTOOLS_SERVICE_NAME: QSGetAllItemsService
            POWERTOOLS_METRICS_NAMESPACE: QSGetAllItemsService
            LOG_LEVEL: Debug
        Events:
          Api:
            Type: Api
            Properties:
              RestApiId: !Ref ApiGatewayApi
              Path: /
              Method: GET
      Metadata: 
        # Manage esbuild properties
        BuildMethod: esbuild
        BuildProperties:
          Minify: true
          Target: "ES2020"
          Sourcemap: true
          EntryPoints:
            - src/GetAllItems/get-all-items.ts

Possible Solution

No response

Steps to Reproduce

  - npm install
  - npm run build

AWS Lambda Powertools for TypeScript version

latest

AWS Lambda function runtime

18.x

Packaging format used

Npm

Execution logs

[Container] 2023/02/08 15:53:25 Running command n 18
  installing : node-v18.14.0
       mkdir : /usr/local/n/versions/node/18.14.0
       fetch : https://nodejs.org/dist/v18.14.0/node-v18.14.0-linux-x64.tar.xz
     copying : node/18.14.0
   installed : v18.14.0 (with npm 9.3.1)

[Container] 2023/02/08 15:53:42 Running command node -v
v18.14.0
[Container] 2023/02/08 15:53:42 Running command echo "Verify AWS CLI Version..."

Verify AWS CLI Version...
[Container] 2023/02/08 15:53:42 Running command aws --version
aws-cli/2.8.1 Python/3.9.11 Linux/4.14.281-212.502.amzn2.x86_64 exec-env/AWS_ECS_EC2 exe/x86_64.ubuntu.22 prompt/off
[Container] 2023/02/08 15:53:53 Phase complete: PRE_BUILD State: SUCCEEDED

[Container] 2023/02/08 15:53:53 Phase context status code:  Message: 
[Container] 2023/02/08 15:53:53 Entering phase BUILD

[Container] 2023/02/08 15:53:53 Running command cd Middy-Crud
[Container] 2023/02/08 15:53:53 Running command npm install
added 591 packages, and audited 592 packages in 17s
found 0 vulnerabilities

[Container] 2023/02/08 15:54:11 Running command npm run build
> [email protected] build

> sam build

    SAM CLI now collects telemetry to better understand customer needs.

    You can OPT OUT and disable telemetry collection by setting the

    environment variable SAM_CLI_TELEMETRY=0 in your shell.

    Thanks for your help!


    Learn More: https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-telemetry.html


Building codeuri: /codebuild/output/src099275065/src/Middy-Crud runtime: nodejs18.x metadata: {'BuildMethod': 'esbuild', 'BuildProperties': {'Minify': True, 'Target': 'ES2020', 'Sourcemap': True, 'EntryPoints': ['src/GetAllItems/get-all-items.ts']}} architecture: x86_64 functions: GetAllItems

Build Failed

Error: 'nodejs18.x' runtime is not supported
@dilippatidar123 dilippatidar123 added triage This item has not been triaged by a maintainer, please wait bug Something isn't working labels Feb 8, 2023
@dreamorosi
Copy link
Contributor

Hello @dilippatidar123, which version of AWS SAM are you using?

The error suggests you're using an older version from before support for nodejs18.x was introduced. Could you please try again with 1.65.0 or newer?

We are aware that the README file could be clearer and specify this minimum version requirement more explicitly (currently it's only specified in the document linked in this section. We are tracking the action in #1273.

Please try again after updating SAM CLI, if the issue persists we'll look at it further.

@dreamorosi dreamorosi added the need-customer-feedback Requires more customers feedback before making or revisiting a decision label Feb 8, 2023
@dreamorosi dreamorosi added documentation Improvements or additions to documentation discussing The issue needs to be discussed, elaborated, or refined and removed bug Something isn't working triage This item has not been triaged by a maintainer, please wait labels Feb 8, 2023
@dreamorosi dreamorosi changed the title Bug: Node 18.x Error for SAM example Docs: Node 18.x Error for SAM example Feb 8, 2023
@dreamorosi
Copy link
Contributor

In #1284 we have added a callout to clarify the minimum SAM CLI version needed to run the examples in the readme:
Screenshot 2023-02-10 at 19 20 16

I'm going to close the issue for now as duplicate of the other one, if you still have issues after upgrading please feel free to reopen.

Thank you for taking the time to report the issue & help improve the project!

@github-project-automation github-project-automation bot moved this from On hold to Coming soon in AWS Lambda Powertools for TypeScript Feb 10, 2023
@dreamorosi dreamorosi moved this from Coming soon to Closed in AWS Lambda Powertools for TypeScript Feb 10, 2023
@github-actions
Copy link
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@dreamorosi dreamorosi added duplicate This issue is a duplicate of an existing one rejected This is something we will not be working on. At least, not in the measurable future and removed need-customer-feedback Requires more customers feedback before making or revisiting a decision discussing The issue needs to be discussed, elaborated, or refined labels Feb 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation duplicate This issue is a duplicate of an existing one rejected This is something we will not be working on. At least, not in the measurable future
Projects
None yet
Development

No branches or pull requests

2 participants