跳到主要内容
ecdsa.com
npm audit signatures (npm 9.5+)包管理器

错误信息

1 package has an invalid registry signature:

也可能输出为

  • Someone might have tampered with this package since it was published on the registry!
  • packages have invalid registry signatures:
  • has a registry signature with keyid: SHA256:demo-registry-key-2026 but no corresponding public key can be found

复数形式:“N packages have invalid registry signatures:”。如果签名的 `keyid` 不在注册表的密钥中,会报错,代码为 `EMISSINGSIGNATUREKEY`(“…has a registry signature with keyid: … but no corresponding public key can be found”);无效的来源证明列在“…has an invalid attestation”之下。

npm audit signatures (npm 9.5+) — registry signature check of installed packages

含义

npm 下载了注册表公开的签名密钥,并检查了每个已安装包的注册表签名——对 `name@version:integrity` 计算的 ECDSA 签名——其中至少有一个包的签名验证未通过。要么包的元数据(包括压缩包的完整性哈希)在注册表签名之后被改动过,要么你安装时使用的注册表用它未公开的密钥签名。npm 会列出受影响的包,最后打印“Someone might have tampered with this package since it was published on the registry!”。

原因

修复方法

  1. 1.

    与公共注册表比对

    如果公共注册表中同一版本的完整性哈希与你的锁文件一致,问题就出在镜像上;如果不一致,说明锁文件或包被改动过。

    bash
    # Same version, straight from the public registry: does the integrity match your lockfile?
    npm view left-pad-lite@1.0.0 dist.integrity --registry https://registry.npmjs.org/
    grep -A3 '"node_modules/left-pad-lite"' package-lock.json | grep integrity
  2. 2.

    在 CI 中运行检查

    在 `npm ci` 之后运行 `npm audit signatures`,遇到未签名、签名错误或来源证明不匹配的依赖时,构建就会失败。

    yaml
    # CI: fail the build on missing or invalid signatures and provenance
    - run: npm ci
    - run: npm audit signatures

相关错误

浏览完整的签名错误库