ARTIFACTORY: NPM-integrity checksum failed when using sha512

AuthorFullName__c
Janardhana JL
articleNumber
000005303
FirstPublishedDate
2022-06-07T09:44:13Z
lastModifiedDate
2025-05-15

ARTIFACTORY: NPM-integrity checksum failed when using sha512

Issue description:

While installing the NPM package sometimes,we would notice checksum integrity failure messages.

This error can occur due to few root causes. While your package.json file is keeping track of NPM package name and version tags of your project dependencies and to preserve the data integrity of all the downloaded packages consistently, the package-lock.json file will also include SHA-512 checksum values of all the objects that were downloaded and during each npm install, NPM will compare and verify the downloading objects against these checksum values saved in the file.
If the content inside any of such npm package gets changed (due to various reasons between the remote and the local, its checksum value will also be different and that would cause a npm package integrity error.

Example error message: 

$ npm i 
npm ERR! code EINTEGRITY
npm ERR! sha512-Xxxxxxxxx == integrity checksum failed when using sha512: wanted sha512-Xabcd== but got sha512- xbjbjbjx. (0 bytes)

 

 Here’s the few possible reason for this issue:

The issue was identified for various reasons, in order to avoid such issues you need to take care at the NPM client side locally or at the Artifactory repository level.
 
 1. Npm client cache may contains incorrect package of same version and tag due to proxy servers, intermediary caches, or target NPM registry can contain wrong package objects (  many similar scenarios due to data corruptions, network package losses, wrong package rebuilds, )
 
 
2. Having corrupted packages inside the Artifactory repository -incorrect package published to the local repository by author, or when the users try to resolve the package from Artifactory NPM remote repository there could be termination in between because of network issue or the package might have been interrupted for some reason which leads to having an incorrect package in the repository, in that case, remove that package and reupload/cache it again.
 
3. When the repository consists of a duplicate package with the same name with different sha values - Hence, avoid publishing the packages with the same name under different repositories.
 
4 . If you found any inconsistency while resolving the package, perform reindexing on the repository and if you notice if the package checksum is null or not calculated try to fix the checksum or clean that package and redeploy or pull the package again.
 

Possible workarounds to fix this issue:

1. To avoid any package creating a conflict in your local system,

  • Remove the node_modules and _cache folder from the .npm location along with the package.json file.
  • Run "npm cache clean --force" command in order to clean the local npm cache.
  •   Next run "npm cache verify"
  •  Try 'npm update'
  • Run 'npm install --verbose'


2. If there is still no change,  delete the package from Artifactory remote cache, right click on the repository, perform zap cache and try to install the package.