aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

=Build Failed Error: NodejsNpmBuilder:

Open sumitjhajharia opened this issue 2 years ago • 2 comments

When i run sam build getting this error:

NpmPack - NPM Failed: npm ERR! code ERR_OUT_OF_RANGE npm ERR! The value of "length" is out of range. It must be >= 0 && <= 2147483647. Received 2955307729

I tried building it without sam and started it using nodejs, it's working fine.

Template File :

AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Template to deploy Lambda for extraction
Resources:
  ExtractionFunction:
    Type: AWS::Serverless::Function
    Properties:
      Handler: index.extractionHandler
      Runtime: nodejs16.x
      Environment:
        Variables:
          S3_KEY: S3_KEY
          S3_SECRET: S3_SECRET
          BUCKET_NAME: BUCKET_NAME
          MY_NAME: MY_NAME

index file :

const { extractionHandler  } =  require('./src/app');

module.exports = { extractionHandler };

node -v : v16.20.2 npm -v : 8.19.4

sumitjhajharia avatar Nov 24 '23 06:11 sumitjhajharia

Hey @sumitjhajharia, can you provide an example of the folder structure of your application?

mildaniel avatar Nov 27 '23 19:11 mildaniel

@mildaniel if i downgrade runtime from node16.x to node14.x , then it's working fine

folder structure - just an index.js file at same level and which exports extractionHandler function to console.log events

sumitjhajharia avatar Nov 30 '23 07:11 sumitjhajharia