npm ERR: Hostname/IP does not match certificate's altnames

Sometimes when build a node docker image will get this error:

npm ERR! request to https://registry.npmjs.org/express failed, reason: Hostname/IP does not match certificate's altnames: Host: registry.npmjs.org. is not in the cert's altnames: DNS:a.sni.fastly.net, DNS:a.sni.global-ssl.fastly.net

The solution is to change registry address, in dockerfile, we can add the following:

FROM node
WORKDIR /app
COPY package.json /app
RUN npm config set registry http://othermirro/
RUN npm config set strict-ssl false
RUN npm install
COPY . ./app
CMD ["npm", "start"]

Comments

Popular posts from this blog

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader.