DEV Community

Discussion on: Run your Github Actions jobs from a specific directory

Collapse
 
corleroux profile image
Cor le Roux

For anyone struggling with the Node Setup action step, specifically with the uses section when your project is in a sub-folder, you need to add a cache-dependency-path to the with section.

Example:


 - uses: actions/setup-node@v2
  with:
    node-version: '14'
    cache: 'npm'
    cache-dependency-path: subdir/package-lock.json`
Enter fullscreen mode Exit fullscreen mode
Collapse
 
rickychongjl profile image
rickychongjl • Edited

To add to this, if your package.lock.json is in another directory, this would most probably mean that you need to target npm build command to that particular directory by adding the default-directory syntax on your steps or job (depending on your setup)

npm:
runs-on: windows-latest
defaults:
run:
working-directory: ./subdir/
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 16
cache: 'npm'
cache-dependency-path: ./subdir/package-lock.json