最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

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

IT培训 admin 11浏览 0评论

将依赖项下载到缓存文件夹(不是./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

我想将依赖项下载到缓存文件夹,例如到此位置的实例:

$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

问题是我不知道如何创建缓存文件夹,但是我认为第二个命令将引用/使用缓存文件夹。

发布评论

评论列表 (0)

  1. 暂无评论