缓存文件夹(不是./node"/>
将依赖项下载到缓存文件夹(不是./node
我想将依赖项下载到缓存文件夹,例如到此位置的实例:
$HOME/.npm/cache
基于package.json文件中列出的依赖项。目标是拥有有用的npm依赖项缓存,npm可以在npm安装步骤中使用它。
我在Dockerfile中具有以下内容:
ARG github_token
ARG commit_id
ADD ".json?token=$github_token" .
RUN npm install --production
RUN rm package.json package-lock.json
RUN git init
RUN git remote add origin "$repo_url"
RUN git fetch --depth 1 origin "$commit_id"
RUN git checkout "$commit_id"
RUN npm install --prefer-offline --cache-min 9999999 --production
[根据经验,我知道npm install
在存在空的node_modules文件夹的情况下更加可靠。因此,我应该做的是代替上面的内容:
ARG github_token
ARG commit_id
ADD ".json?token=$github_token" .
RUN npm install --production ### how to install to cache folder instead of ./node_modules?
没有人知道如何将node_modules缓存在./node_modules以外的位置吗?
回答如下:这不太正确:
npm install '.' --cache /tmp/npm-tmp-cache ### how to create the cache??
然后再来:
npm install --cache /tmp/npm-tmp-cache ### this will use the cache
问题是我不知道如何创建缓存文件夹,但是我认为第二个命令将引用/使用缓存文件夹。
更多推荐
将依赖项下载到缓存文件夹(不是./node
发布评论