我尝试构建节点应用程序的映像,但在执行时显示错误。
PS C:\Users\vallabh\Desktop\visits> docker build .
[+] Building 3.8s (5/5) FINISHED
[internal] load build definition from Dorkerfile
=> transferring Dockerfile! 31B
=> [internal] load .dockerignore
=> => Transferring context: 2B
=> [internal] load metadata for docker.io/library/node:alpine
=> CACHED [1/2] FROM docker.io/library/node:alpine@sha256 :0677e437543016F6cb058d92792a14e5eb84348e3d5b4
> ERROR [2/2] RUN npm install:
确切的误差为:
------
> [2/2] RUN npm install:
#5 1.745 npm ERR! Tracker "idealTree" already exists
#5 1.748
#5 1.748 npm ERR! A complete log of this run can be found in:
#5 1.748 npm ERR! /root/.npm/_logs/2022-05-28T07_47_19_509Z-debug-0.log
------
executor failed running [/bin/sh -c npm install]: exit code: 1
PS C:\Users\vallabh\Desktop\visits> executor failed running [/bin/sh -c npm install]: exit code: 1D
如何避免此npm install
错误?
举例说明:
2条答案
按热度按时间zu0ti5jz1#
首先检查您是否有类似的问题as in here:
此问题的发生是由于NodeJS从版本15开始的更改。
如果未指定
WORKDIR
,则在容器的根目录中执行npm install
,从而导致此错误。在
WORKDIR
指定的容器的项目目录中执行npm install
可以解决此问题。在您的情况下,请确保将
WORKDIR
设置为您的节点应用程序在您正在构建的映像中驻留的位置。cpjpxq1n2#
我已经在Dokerfile中包含了节点版本。对我有效