首页 > 解决方案 > npm 错误!结束后写。在 docker、aws 中运行 npm 安装失败

问题描述

尝试跑步时,docker build -t app . --memory 3G --memory-swap 4G我遇到

 Step 8/11 : RUN npm install
 ---> Running in 5283e1139345
    npm WARN deprecated browserslist@2.11.3: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
    npm WARN deprecated fs-promise@2.0.3: Use mz or fs-extra^3.0 with Promise Support
    npm WARN deprecated tar.gz@1.0.7: ⚠️  WARNING ⚠️ tar.gz module has been deprecated and your application is vulnerable. Please use tar module instead: https://npmjs.com/tar
    npm ERR! write after end

有谁知道是什么导致了这个错误?为什么没有安装 npm?我将 aws 与 Docker 结合使用。

Dockerfile 如下图所示

FROM ubuntu:18.04

WORKDIR /app
COPY . .

# If you have native dependencies, you'll need extra tools
# RUN apk add --no-cache make gcc g++ python
RUN apt-get update \
  && apt-get install -y --no-install-recommends apt-utils -y \
  && apt-get install curl -y \
  && apt-get install git-core -y \
  && curl -sL https://deb.nodesource.com/setup_8.x \
  && apt-get install -y nodejs npm \
  && curl https://cmake.org/files/v3.11/cmake-3.11.3-Linux-x86_64.sh -o /tmp/curl-install.sh \
  && chmod u+x /tmp/curl-install.sh \
  && mkdir /usr/bin/cmake \
  && /tmp/curl-install.sh --skip-license --prefix=/usr/bin/cmake \
  && rm /tmp/curl-install.sh \
  && apt-get install libpq-dev -y \
  && apt-get install libboost-all-dev -y \
  && apt-get install postgresql-server-dev-all -y

ENV PATH="/usr/bin/cmake/bin:${PATH}"

RUN npm install -g npm@5

RUN ./move-cpp-files.sh
RUN npm install
RUN npm run compile

EXPOSE 3000
CMD ["npm", "start"]

标签: node.jsdockernpm

解决方案


您可能正在安装有此问题的 NPM 版本:

RUN npm install -g npm@5

尝试不使用该行还是有特定原因?


推荐阅读