[Solved] Docker npm install: npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY.. reason: unable to get local issuer certificate

This is because a certificate is required, which makes it impossible to connect. The temporary solution is to set npm set strict-ssl=false

In the dockerfile file: Add RUN npm set strict-ssl=false before run NPM install

FROM node:12

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm set strict-ssl=false

RUN npm install
# If you are building your code for production
# RUN npm ci --only=production

# Bundle app source
COPY . .

EXPOSE 8080

CMD [ "node", "server.js" ]

connect:

Dockerize a Node.js web application: https://nodejs.org/en/docs/guides/nodejs-docker-webapp/

Similar Posts: