npm install: ERR_SSL_CIPHER_OPERATION_FAILED and ERR_SSL_CIPHER_OPERATION_FAILED

I got these errors after trying to run npm install.

# npm install

...
npm ERR! gyp ERR! UNCAUGHT EXCEPTION
npm ERR! gyp ERR! stack TypeError: Cannot assign to read only property 'cflags' of object '#<Object>'
npm ERR! gyp ERR! stack     at createConfigFile (/app/node_modules/node-gyp/lib/configure.js:117:21)
npm ERR! gyp ERR! stack     at /app/node_modules/node-gyp/lib/configure.js:84:9
npm ERR! gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:191:23)
npm ERR! gyp ERR! System Linux 6.6.12-linuxkit
npm ERR! gyp ERR! command "/usr/local/bin/node" "/app/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /app/node_modules/node-sass
npm ERR! gyp ERR! node -v v20.11.1
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! Node-gyp failed to build your package.
npm ERR! gyp ERR! Try to update npm and/or node-gyp and if it does not help file an issue with the package author.
npm ERR! Build failed with error code: 7

I did the following to fix these

  • installed system packages
  • updated node to the current version (not LTS)
  • update npm to the latest version
  • update node_gyp to the latest version
  • updated all versions in package.json to the latest versions
  • removed package-lock.json file
  • removed node_modules directory
  • cleaned npm cache
  • ran npm install again

I installed the following packages:

# apt-get update && apt-get install -y ca-certificates curl gnupg zip unzip git software-properties-common rsyslog

Upgraded node, npm, node_gyp and cleared cache

 # npm cache clean -f \
  && npm install -g n \
  && n current
# npm install -g npm@latest
# npm update -g node-gyp
# rm -rf node_modules package-lock.json

Then, update all package versions in package.json to their latest version.

And then tried again, this time it worked.

# npm install

Did this work for you as well? Had to do less? More? Let me know and I’ll update this post.

Click Here to Leave a Comment Below

Leave a Reply: