docker npm install Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443

前端 未结 7 1370
Happy的楠姐
Happy的楠姐 2020-12-16 23:48

I\'m using docker version 1.10.1 on RHEL 7 and getting npm install error when using below Dockerfile. The Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:

相关标签:
7条回答
  • 2020-12-17 00:19

    I was following a tutorial. This error doesn't happen for me when I copy all my files:

    # Specify base image
    FROM node:alpine
    
    WORKDIR /usr/app
    
    # Install dependencies
    COPY ./ ./
    RUN npm install
    
    # Default command
    CMD ["npm", "start"]
    

    It happens with me when I copy package.json first and then copy other files after npm install:

    # Specify base image
    FROM node:alpine
    
    WORKDIR /usr/app
    
    # Install dependencies
    COPY ./package.json ./
    RUN npm install
    
    COPY ./ ./
    
    # Default command
    CMD ["npm", "start"]
    
    0 讨论(0)
提交回复
热议问题