Creating NodeJS Lambda - identical content, distinct SHA checksum

I'm encountering a perplexing issue and I can't seem to identify the root cause. Let me share my experience:

My objective is to utilize Terraform for managing Lambda functions, with CircleCI serving as the orchestrator. The process unfolds as follows:

GitHub repository -> CircleCI build (npm install && zip) -> aws s3 sync ZIP to S3 -> Terraform retrieves ZIP from S3 -> deploy to Lambda if SHA differs.

Everything operates smoothly except for one minor hiccup. Whenever I run the entire process twice without any modifications in the GitHub repository, Terraform consistently reports a new SHA hash:

source_code_hash: "mx56e7pMbBdftYHes+pETvjFZInvKsP92vtZ5URqyJY=" => "dhe66opfifDLEr7wI+Ie9UE6ioUiG8hTajuPhctA+W0="

It appears that the issue may be related to the npm install process, which could potentially produce slightly different outcomes each time. I doubt that zipping the folder should cause any trouble, as it's a straightforward zip -r file.zip *.

Could anyone provide an explanation for this behavior?

Answer №1

npm install with versions 4 or earlier can result in non-deterministic outcomes, meaning that your npm install may not produce the same results in different builds.

npm addressed this issue with version 5's package-lock.json. Consider updating to the latest version of npm to resolve this problem.

Alternatively, you can explore using yarn or pnpm, which are alternative package managers designed to ensure deterministic installs.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Centralized platform for accessing node and npm installers that adhere to Nexus standards

I am searching for a nexus-compliant repository where I can find a node installer that aligns with Nexus guidelines (an alternative to http://nodejs.org/dist/). Situation : In our Java environment, Maven handles our builds. We recently integrated a JavaS ...

Error in node: nodenv could not locate any specified version for use

Following a successful installation of Node, I encountered the following error message: $ npm nodenv: couldn't find any version specified for use $ node nodenv: couldn't find any version specified for use Does anyone have insight into where thi ...

Error in Svelte/Typescript: Encounter of an "unexpected token" while declaring a type

Having a Svelte application with TypeScript enabled, I encountered an issue while trying to run it: [!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript) src\api.ts (4:7) 2: 3: export default class API { 4: ...

Having trouble with npm publish on AWS CodeArtifact?

I am currently facing an issue with using npm publish to publish a JavaScript library to a private NPM repository hosted on AWS CodeArtifact. Interestingly, when I execute npm publish on my local machine, it works perfectly fine. However, when I attempt t ...

Opening multiple scripts in individual terminal windows within VSCODE is a great method for better organization and efficiency

When setting up my development environment, I find it necessary to run multiple scripts. I have a preference for using VSCode. Although utilizing tools like concurrently is helpful, I would prefer each script to run in its own terminal window so that I ca ...

Building with a specific version in NPM

Is there a method to automatically update the version number in my react app's package.json file using command line? Specifically, can this be done with npm build or before/after running npm build? I have a build server set up to execute npm build an ...

The error being thrown at line 538 in the module.js file is causing issues when using

I encountered an error in my Angular 4 project that says "module.js:538 throw err;". Can anyone provide insight on what this means? module.js:538 throw err; ^ Error: Cannot find module 'swagger-js-codegen' at Function.Module._resolveFilena ...

What are the steps to set up Node.js, npm, and socket.io and start using them?

Hello there! I'm new to the world of Node.js and I'm hoping someone can help me out. Can you provide a detailed, step-by-step guide on how to install Node.js, npm and socket.io? Thanks in advance! ...

What sets apart dependencies, devDependencies, and peerDependencies within an NPM package.json file?

I found this documentation to be inadequate in addressing my question. The explanations provided were difficult for me to grasp. Can someone please explain it more simply, perhaps with the help of examples if necessary? Additionally, I am also confused ab ...

Discovering the appropriate node version for a project

Is it possible to determine the appropriate node version for a repository without resorting to trial and error? As web frameworks continue to evolve rapidly, revisiting projects from months or even years ago has become a common occurrence. I've foun ...

Issue encountered while building Angular application at ./node_modules/@syncfusion/ej2-angular-richtexteditor/@syncfusion/ej2-angular-richtexteditor.es5.js

We have specified the following versions in our package.json file: "@syncfusion/ej2-angular-richtexteditor": "^17.3.28", "typescript": "^3.1.3", and "@angular/cli": "^7.0.3". During the project build process using npm run build:ssr, we encountered the err ...

Guide on resolving the npm install issue "npm ERR! code 1"

My attempt to set up Gulp.js is running into issues. When I input npm install, the following error arises: npm ERR! code 1 npm ERR! path D:\www\wegrow\node_modules\node-sass npm ERR! command failed ... npm ERR! gyp ERR! not ok npm ERR! ...

Android's Edge browser now allows users to subscribe to web push notifications using the npm command, which will return an

Recently, I encountered a strange issue with the node.js web-push functionality that had been working flawlessly across different browsers and platforms. Everything was going smoothly on Chrome, Firefox, Opera, and even on Android, until I tested it on t ...

The React project encountered a build failure following the execution of the npm run command, resulting in the error code ELIFCY

I encountered an error while attempting to run my React project on localhost. Is there anyone who can provide assistance? Here is the error log: C:\Users\Intel\Desktop\burger-project>npm start > <a href="/cdn-cgi/l/email-prote ...

Error: Failed to locate package "package-name" in the "npm" registry during yarn installation

While working on a large project with numerous sub-projects, I attempted to install two new packages. However, YARN was unable to locate the packages despite the .npmrc being present in the main directory. ...

When trying to use npm install, the process is being interrupted by receiving both 304 and 404

Whenever I execute the npm install command, my console floods with this: npm http fetch GET 304 http://registry.npmjs.org/is-arrayish 60ms (from cache) npm http fetch GET 304 http://registry.npmjs.org/spdx-license-ids 67ms (from cache) npm http fetch GET ...

Step-by-step guide on installing solely 'devDependencies' with npm

Looking to specifically install only the "devDependencies" from my package.json file, I've attempted various commands with no success. Each command ends up installing both production and development dependencies, which is not what I want. npm install ...

"Exploring the intricate world of Node module versioning

Having a node module called demo-npm-module, with various versions published on npm such as: 1.0.0 1.1.0 2.0.0 3.0.0 I encountered an issue where I needed to fix a bug in an older version like 1.1.0, leading to an update to version 1.1.1. After making an ...

Issue with deploying Firebase Cloud Functions - Deployment Failed

Oh man, I am at my wit's end with this issue... Despite following all the correct steps for Firebase cloud functions, I keep encountering an error while trying to deploy: Build failed: Specified version range of module @firebase/app is not a strin ...

Guide on launching an Angular 12 project with the help of Angular CLI 13

After downloading an Angular 12 project, I attempted to run it using Angular 13 (the latest version). However, I encountered issues when trying to run it. Even after attempting to use npm install, I still faced dependency problems. Errors occurred when ru ...