同事遇到这个问题

    1. + npm install --no-optional --production
    2. npm ERR! code EINTEGRITY
    3. npm ERR! sha512-nADAsJGM8jw18ufzd8/a26rC/+JVJCpLFH3fUkkxaXyMvDoAK99BDdAL5UqN9XZUj85nwM/3Lxbw8N9BRppFGA== integrity checksum failed when using sha512: wanted sha512-nADAsJGM8jw18ufzd8/a26rC/+JVJCpLFH3fUkkxaXyMvDoAK99BDdAL5UqN9XZUj85nwM/3Lxbw8N9BRppFGA== but got sha512-s9YhDRKaBS2uLucU30Cy5td+81hr1Vj+rn0m7b1U7mpcUNPUNwil7ifZS6m5b1Jqy6jh86WrRr37GqCmd3Lpqw==. (7539 bytes)

    npm 包的校验值被变更,导致不一致(integrity: A sha512 or sha1 Standard Subresource Integrity string for the artifact that was unpacked in this location.)

    临时解决方案是使用 npm config set package-lock false

    这个可能是私有库选择的版本策略不正确, 需要设置为禁止覆盖。如果被同一版本的包被修改覆盖了,就会导致校验值不一致

    nexus 版本策略:允许覆盖、禁止覆盖、只读。(向nexus服务发布NPM包时,使用的策略)

    npm ERR! code EINTEGRITY - 图1

    改为以上方案后,删除 package-lock.json,执行 npm cache clean —force 重新安装依赖,发布,还是报 npm ERR! code EINTEGRITY

    1. + npm install --no-optional --production
    2. npm ERR! sha512-u9bxXv/UdLofvLRmJFK1fxoGwAEWuGtCxtwu9iQZwP5HDTRdY1zs9exWwVm/7+M83xjiB4xjUQDXHn8ypC864A== integrity checksum failed when using sha512: wanted sha512-u9bxXv/UdLofvLRmJFK1fxoGwAEWuGtCxtwu9iQZwP5HDTRdY1zs9exWwVm/7+M83xjiB4xjUQDXHn8ypC864A== but got sha512-s9YhDRKaBS2uLucU30Cy5td+81hr1Vj+rn0m7b1U7mpcUNPUNwil7ifZS6m5b1Jqy6jh86WrRr37GqCmd3Lpqw==. (7539 bytes)

    可能第一次没执行好,我重新执行后,package-lock.json 又有变化,重新提交好了,执行脚本如下

    1. rm -rf node_modules
    2. npm cache verify
    3. npm cache clean --force
    4. npm i
    5. # 之后重新提交代码,成功

    参考: