DEV Community

Sardorbek Imomaliev
Sardorbek Imomaliev

Posted on

13 3

TIL: GitHub Actions | Fix "Error: Dependencies lock file is not found"

Question

How to fix this error:

Error: Dependencies lock file is not found in /path/to/project. Supported file patterns: package-lock.json,yarn.lock
Enter fullscreen mode Exit fullscreen mode

in actions/setup-node@v2 GitHub Action?

Answer

This error occurs because by default, this job searches for package-lock.json in the root of the repository for caching. We need to explicitly specify the location of our package-lock.json

             - name: Setup Node.js
               uses: actions/setup-node@v2
               with:
                   node-version: 16.14.0
                   cache: "npm"
+                  # The action defaults to search for the dependency file
+                  # (package-lock.json or yarn.lock) in the repository root, and uses
+                  # its hash as a part of the cache key.
+                  # https://github.com/actions/setup-node#caching-packages-dependencies
+                  cache-dependency-path: "./blog/package-lock.json"
Enter fullscreen mode Exit fullscreen mode

Links

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (4)

Collapse
 
forinda profile image
Orinda Felix Ochieng

What if you are using pnpm package manager?

Collapse
 
imomaliev profile image
Sardorbek Imomaliev

@forinda Never used pnpm, try checking docs github.com/actions/setup-node/blob...

Collapse
 
forinda profile image
Orinda Felix Ochieng

Ok. Sure...

Collapse
 
yoloz profile image
yoloz

thanks

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay