The DEPTH_ZERO_SELF_SIGNED_CERT error occurs when npm encounters a self-signed certificate at the root of the chain (depth zero). This means the first certificate in the chain is self-signed, with no chain of trust.
This error indicates that the very first certificate encountered (at "depth zero" in the certificate chain) is self-signed. Unlike SELF_SIGNED_CERT_IN_CHAIN where a self-signed certificate appears somewhere in the chain, this error means there's no certificate chain at all - just a single self-signed certificate. This commonly occurs with development servers, local registries, or proxies using certificates generated with tools like openssl or mkcert without establishing proper trust.
Check the certificate details:
openssl s_client -connect your-registry:443 2>/dev/null | openssl x509 -noout -issuer -subjectIf Issuer equals Subject, it's self-signed.
Get the certificate for trust configuration:
openssl s_client -connect your-registry:443 </dev/null 2>/dev/null | openssl x509 > self-signed.crtOr export from browser if accessible via HTTPS.
Configure npm to trust this certificate:
npm config set cafile /path/to/self-signed.crtOr for the specific registry:
npm config set //your-registry:443/:cafile /path/to/self-signed.crtFor system-wide trust:
# Ubuntu/Debian
sudo cp self-signed.crt /usr/local/share/ca-certificates/
sudo update-ca-certificates
# macOS
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain self-signed.crt
# Windows (run as admin)
certutil -addstore -f "ROOT" self-signed.crtUse mkcert for trusted local certificates:
# Install mkcert
brew install mkcert # macOS
# Install local CA
mkcert -install
# Generate certificate for your registry
mkcert localhost 127.0.0.1 ::1mkcert automatically trusts its certificates.
⚠️ Never use in production:
npm config set strict-ssl falseOr per-command:
npm install --strict-ssl=falseFor production private registries, use certificates from a real CA (Let's Encrypt is free) rather than self-signed. In Kubernetes, use cert-manager for automatic certificate management. For development, mkcert creates locally-trusted certificates that work across tools. When distributing to teams, document CA installation steps or use configuration management.
npm ERR! code ENOAUDIT npm ERR! Audit endpoint not supported
How to fix "npm ERR! code ENOAUDIT - Audit endpoint not supported"
npm ERR! code EBADDEVENGINES npm ERR! devEngines.runtime incompatible with current node version
How to fix "npm ERR! code EBADDEVENGINES - devEngines.runtime incompatible with current node version"
npm ERR! code ETOOMANYARGS npm ERR! Too many arguments
How to fix "npm ERR! code ETOOMANYARGS - Too many arguments"
npm ERR! code EINVALIDTAGNAME npm ERR! Invalid tag name: tag names cannot contain spaces
How to fix "npm ERR! code EINVALIDTAGNAME - tag names cannot contain spaces"
npm ERR! code E400 npm ERR! 400 Bad Request
How to fix "npm ERR! code E400 - 400 Bad Request" error