[英]Does the npm cache speed up `npm install`?
考慮以下構建:
這兩個存儲庫幾乎相同,唯一的區別是后者存儲庫通過setup-node
GitHub Action 緩存npm
,而前者沒有。 換句話說,存儲庫之間的唯一區別在於.github/workflows/main
文件:
name: Build Pipeline
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '11'
# Following line is present only on the latter repository
cache: 'npm'
- run: npm install
- run: npm run build
盡管“setup-node-with-cache”的構建成功地使用了 npm 緩存(如Run actions/setup-node@v2
步驟的 output 所示), Run npm install
步驟幾乎相同在“setup-node-without-cache”處構建的步驟。
Run npm install
步驟在“setup-node-with-cache”處的構建步驟的運行時間是否應該明顯短於“setup-node-without-cache”處構建的相應步驟,因為它是應該使用緩存的 npm 包? 我在這里錯過了什么嗎?
至少在 GitHub Actions 上似乎不是這樣。 我發現的解決方法是緩存實際的node_modules
文件夾,即使它“不推薦”。 緩存實際的node_modules
文件夾確實加快了npm install
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.