2

A friend shared with me a theme he is developing for WordPress, and I cloned his repo in my /themes folder, first thing I tried was to run "npm install" in the theme folder in order to get gulp and other npm cool features.

This is what it returns:

$ npm install
npm ERR! code EINTEGRITY
npm ERR! sha1-fjL3W0e4epHQRhHxvxQQmsAGUdc= integrity checksum failed when using sha1: wanted sha1-fjL3W0e4epHQRhHxvxQQmsAGUdc= but got sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw== sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=. (36808 bytes)

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\rinor\AppData\Roaming\npm-cache\_logs\2020-04-04T17_30_54_859Z-debug.log

After trying installing it globally it gave me back the same error so I came up with uninstalling node.js from my pc and then download and install the LTS version (12.16.1). Rebooted, tested and it seemed to work as I tried typing "node -v" && "npm -v". But when I return to my theme and go for "npm install" it gives me the same error.

Here is my package.json content

{
  "name": "ruce-theme",
  "version": "1.0.0",
  "description": "A starter theme",
  "scripts": {
    "watch": "gulp watch"
  },
  "dependencies": {
    "bootstrap": "^4.0.0-beta.3",
    "jquery": "^3.2.1",
    "npm": "^6.4.1",
    "slick-carousel": "^1.8.1"
  },
  "devDependencies": {
    "@babel/core": "^7.3.3",
    "@babel/preset-env": "^7.3.1",
    "@babel/preset-react": "^7.0.0",
    "babel-core": "^6.25.0",
    "babel-loader": "^8.0.5",
    "babel-plugin-transform-react-jsx": "^6.24.1",
    "babel-preset-env": "^1.6.0",
    "cross-env": "^5.0.1",
    "css-loader": "^2.1.0",
    "extract-text-webpack-plugin": "^4.0.0-beta.0",
    "file-loader": "^3.0.1",
    "gulp": "^4.0.0",
    "gulp-babel": "^8.0.0-beta.2",
    "gulp-clean-css": "^3.9.1",
    "gulp-clone": "^1.1.4",
    "gulp-concat": "^2.6.1",
    "gulp-cssnano": "^2.1.2",
    "gulp-ignore": "^2.0.2",
    "gulp-imagemin": "^4.0.0",
    "gulp-merge": "^0.1.1",
    "gulp-plumber": "^1.2.0",
    "gulp-rename": "^1.2.2",
    "gulp-rimraf": "^0.2.2",
    "gulp-sass": "^3.1.0",
    "gulp-sequence": "^0.4.6",
    "gulp-sourcemaps": "2.6.2",
    "gulp-uglify": "^3.0.0",
    "gulp-watch": "^4.3.11",
    "node-sass": "^4.11.0",
    "sass-loader": "^7.1.0",
    "style-loader": "^0.23.1",
    "webpack": "^4.29.0",
    "webpack-cli": "^3.2.1"
  },
  "license": "ISC"
}

These are the erros that the debug shows

20111 error code EINTEGRITY
20112 error sha1-fjL3W0e4epHQRhHxvxQQmsAGUdc= integrity checksum failed when using sha1: wanted sha1-fjL3W0e4epHQRhHxvxQQmsAGUdc= but got sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw== sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=. (36808 bytes)
20113 verbose exit [ 1, true ]

2 Answers2

1

You don't mention whether you had package-lock.json or not. In some cases the following might help. But first make sure you understand what's going on. npm tells you that the checksum from https://registry.npm.org doesn't match the one from package-lock.json. Either it changed in the registry, or...

Solution Consider the line from the output:

npm ERR!
  sha1-fjL3W0e4epHQRhHxvxQQmsAGUdc=
integrity checksum failed when using sha1: wanted
  sha1-fjL3W0e4epHQRhHxvxQQmsAGUdc=
but got
  sha512-kV/CThkXo6xyFEZUugw/+pIOywXcDbFYgSct5cT3gqlbkBE1SJdwy6UQoZvodiWF/ckQLZyDE/Bu1M6gVu5lVw== sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=
. (36808 bytes)

Find the package in package-lock.json by the first two integrity checksums (sha1-...), and put the third one (sha512-...) into its "integrity" field.

More on it here.

x-yuri
  • 16,722
  • 15
  • 114
  • 161
0

I faced the same issue. If the npm package in repository is updated with the same version, the checksum changes and npm raises an error. To overcome the issue I simply

  1. deleted the node-modules
  2. cleared the npm cache
  3. changed a different valid version of the package
  4. ran npm install
  5. changed the package version again to the one that I want to use
  6. ran npm install

Thus, the checksum updated and npm installed the desired package correctly.

But, most probably, applying the 3 to 6 would be enough imho.

Npm raises the error because the checksum is saved to the package-lock.json and we cannot modify it customly.

Bahadir Tasdemir
  • 10,325
  • 4
  • 49
  • 61