神奇的npm - npm i時提示sha512錯誤

Alongite發表於2019-02-28
npm ERR! code EINTEGRITY
npm ERR! sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA== integrity checksum failed when using sha512: wanted sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA== but got sha512-WXI95kpJrxw4Nnx8vVI90PuUhrQjnNgghBl5tn54rUNKZYbxv+4ACxUzPVpJEtWxKmeDwnQrzjc0C2bYmRJVKg==. (65117 bytes)

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/ubuntu/.npm/_logs/2017-11-29T05_33_52_182Z-debug.log
複製程式碼

下載npm包的時候,會進行包的雜湊檢測,以防下載的包被人惡意篡改,然而有時候因為cnpm與npm混用導致這個問題,可以通過以下步驟解決

  1. 刪除package-lock.json,重新執行npm i
  2. rm -r package-lock.json node-modules && npm cache clean --force && npm install

相關文章