npm安装需要(30+)分钟

时间:2019-07-16 08:25:48

标签: docker jenkins npm debian install

debian 9.8上运行的服务器中,

npm安装需要30分钟以上的时间。 我想知道是什么原因造成的?

我已经尝试过npm set progress=falsenpm config set registry http://registry.npmjs.org/,但是都没有帮助。 我正在docker容器中运行它。

这是我的package.json

{
    "name": "name",
    "version": "1.0.0",
    "main": "server/server.js",
    "engines": {
        "node": ">=6"
    },
    "scripts": {
        "lint": "eslint .",
        "start": "nodemon .",
        "client": "cd client && npm start",
        "test": "mocha"
    },
    "dependencies": {
        "babel-eslint": "^10.0.1",
        "compression": "^1.0.3",
        "cors": "^2.5.2",
        "eslint-config-react-app": "^4.0.0",
        "eslint-plugin-flowtype": "^3.7.0",
        "eslint-plugin-import": "^2.17.2",
        "eslint-plugin-jsx-a11y": "^6.2.1",
        "eslint-plugin-react": "^7.13.0",
        "eslint-plugin-react-hooks": "^1.6.0",
        "express-jwt": "^5.3.1",
        "express-winston": "^3.2.0",
        "helmet": "^3.10.0",
        "html-element": "^2.3.0",
        "jwks-rsa": "^1.5.1",
        "libxmljs": "^0.19.5",
        "loopback": "^3.22.0",
        "loopback-boot": "^2.6.5",
        "loopback-component-explorer": "^6.2.0",
        "loopback-connector-mongodb": "^4.2.0",
        "loopback-connector-rest": "^3.4.1",
        "node": "8.16.0",
        "node-blockly": "^1.0.36",
        "serve-favicon": "^2.0.1",
        "strong-error-handler": "^3.0.0",
        "winston": "^3.2.1"
    },
    "devDependencies": {
        "chai": "^4.2.0",
        "eslint": "^3.17.1",
        "eslint-config-loopback": "^8.0.0",
        "loopback-supertest-models": "^3.5.0",
        "mocha": "^6.1.4",
        "nodemon": "^1.19.0",
        "supertest": "^4.0.2"
    },
    "repository": {
        "type": "",
        "url": ""
    },
    "license": "UNLICENSED",
    "description": "description"
}

这是我的Dockerfile

FROM node:10.9.0-alpine as builder

RUN mkdir -p /app/server
WORKDIR /app/server

COPY package*.json /app/server/
#COPY yarn* /app/server/

# Disables npm progress bar
RUN npm set progress=false
# Set npm registry to http://registry.npmjs.org
RUN npm config set registry http://registry.npmjs.org/

#! Install the build requirements for bcrypt
RUN apk update && apk upgrade \
  && apk --no-cache add --virtual git builds-deps build-base \
  && apk --no-cache add make gcc g++ python \
  && npm install --save node-gyp node-pre-gyp \
  && rm -rf /var/cache/apk/* 
  # && yarn add node-gyp node-pre-gyp

# Install dependencies
# RUN yarn install --production=true
RUN npm install --production

# Copy the server files over
COPY . /app/server/

RUN apk del make gcc g++ python

FROM node:10.9.0-alpine

# Create and set the working directory
RUN mkdir -p /app/server
WORKDIR /app/server

# Copy the server from the build container
COPY --from=builder /app/server /app/server

CMD ["node", "."]

0 个答案:

没有答案