【发布时间】:2022-02-17 16:35:53
【问题描述】:
npm install 的 docker 构建问题,它只在我测试过的 docker 内部。它在我的操作系统上完美运行
错误
Step 6/8 : RUN npm cache clear --force && npm install --legacy-peer-deps
---> Running in 361c2a07ac22
npm WARN using --force Recommended protections disabled.
npm notice
npm notice New minor version of npm available! 8.4.1 -> 8.5.0
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.5.0>
npm notice Run `npm install -g npm@8.5.0` to update!
npm notice
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! errno ERR_SOCKET_TIMEOUT
npm ERR! network Invalid response body while trying to fetch https://registry.npmjs.org/styled-jsx: Socket timeout
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-02-17T07_12_06_500Z-debug-0.log
The command '/bin/sh -c npm cache clear --force && npm install --legacy-peer-deps' returned a non-zero code: 1
泊坞窗文件
FROM node:alpine
WORKDIR /app
ENV PORT 3000
COPY ./package.json /app/
COPY ./.npmrc ~
RUN npm cache clear --force && npm install --legacy-peer-deps
COPY . /app/
CMD ["npm", "start"]
如您所见,我添加了 .npmrc 文件,因为我在某处读过它,但它不起作用或添加 npm cache clear --force 那么我该怎么办?
【问题讨论】:
-
也许像
RUN npm cache clear --force和RUN npm install --legacy-peer-deps这样分开两行来分别查看日志?
标签: javascript node.js docker npm