Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

997
Views
Sam build fails with: Build Failed Error: NodejsNpmBuilder:NpmPack - NPM Failed: npm ERR! code Z_DATA_ERROR

I'm learning how to create lambdas on aws. I'm following this official tutorial.

The commands I run:

sam init (default values for everything, I'm choosing template 8 - webapp backend)

cd sam-app

sam build

The output I'm getting is:

Building codeuri: /home/sam-app runtime: nodejs14.x metadata: {} functions: ['getAllItemsFunction', 'getByIdFunction', 'putItemFunction']
Running NodejsNpmBuilder:NpmPack

Build Failed
Error: NodejsNpmBuilder:NpmPack - NPM Failed: npm ERR! code Z_DATA_ERROR
npm ERR! errno -3
npm ERR! zlib: invalid distance too far back

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/username/.npm/_logs/2021-05-20T14_02_59_425Z-debug.log

node version: 16.2.0

npm version: 7.13.0

sam version: 1.23.0

zlib version: 1:1.2.11-4

I'm not modifying any files - they're all generated by sam.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Try building this in a container. Use sam build -u

This worked for me, but I am not sure why it wouldn't build without this.

over 4 years ago · Santiago Trujillo Report

0

I had the same problem in wsl2, I have solved it by installing a newer version of nodejs(v14.17.1) with nvm https://docs.microsoft.com/en-us/windows/dev-environment/javascript/nodejs-on-wsl https://github.com/nvm-sh/nvm#git-install

over 4 years ago · Santiago Trujillo Report

0

Maybe in your template file, you might be using the below type

Type: AWS::Lambda::Function

If that's the case then change the type to below one

Type: AWS::Serverless::Function

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!