将依赖项下载到缓存文件夹(不是./node

编程入门 行业动态 更新时间:2024-10-13 10:25:32

将依赖项下载到<a href=https://www.elefans.com/category/jswz/34/1771061.html style=缓存文件夹(不是./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

本文发布于:2024-05-07 06:42:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1754888.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:缓存   文件夹   node

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!