[GH-ISSUE #86] Can't install npm dependencies #54

Closed
opened 2026-03-01 21:39:30 +03:00 by kerem · 10 comments
Owner

Originally created by @finleygn on GitHub (Feb 20, 2020).
Original GitHub issue: https://github.com/nektos/act/issues/86

I've been trying to get my github actions working locally with act (really cool tool btw) but I can't seem to get npm working.

Heres an example workflow to show the problem:

name: Test Somethin

on:
  pull_request:
    branches:
      - develop

jobs:
  do-stuff:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v1
        with:
          node-version: 12
          registry-url: https://registry.npmjs.org/

      - name: Install Dependencies
        run: npm install
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Running command act -j do-stuff -s NPM_TOKEN=XXXX_XXXX_XXXX
I get this output

[Test Somethin/do-stuff] ⭐  Run actions/checkout@v2
[Test Somethin/do-stuff]   ✅  Success - actions/checkout@v2
[Test Somethin/do-stuff] ⭐  Run actions/setup-node@v1
[Test Somethin/do-stuff]   ☁  git clone 'https://github.com/actions/setup-node' # ref=v1
[Test Somethin/do-stuff]   🐳  docker pull node:12-alpine
[Test Somethin/do-stuff]   🐳  docker run image=node:12-alpine entrypoint=[] cmd=["node" "/github/home//setup-node985111831/dist/index.js"]
[Test Somethin/do-stuff]   💬  ::debug::isExplicit:
[Test Somethin/do-stuff]   💬  ::debug::explicit? false
[Test Somethin/do-stuff]   💬  ::debug::evaluating 0 versions
[Test Somethin/do-stuff]   💬  ::debug::match not found
[Test Somethin/do-stuff]   💬  ::debug::evaluating 378 versions
[Test Somethin/do-stuff]   💬  ::debug::matched: v12.16.1
[Test Somethin/do-stuff]   💬  ::debug::isExplicit: 12.16.1
[Test Somethin/do-stuff]   💬  ::debug::explicit? true
[Test Somethin/do-stuff]   💬  ::debug::checking cache: /home/actions/cache/node/12.16.1/x64
[Test Somethin/do-stuff]   💬  ::debug::not found
[Test Somethin/do-stuff]   💬  ::debug::Downloading https://nodejs.org/dist/v12.16.1/node-v12.16.1-linux-x64.tar.gz
[Test Somethin/do-stuff]   💬  ::debug::Downloading /home/actions/temp/1a31fd1a-a499-4e30-9d38-531f090e84b2
[Test Somethin/do-stuff]   💬  ::debug::download complete
[Test Somethin/do-stuff]   💬  ::debug::Caching tool node 12.16.1 x64
[Test Somethin/do-stuff]   💬  ::debug::source dir: /home/actions/temp/692cf33e-d4ab-4040-a505-f1e4bd026f89/node-v12.16.1-linux-x64
[Test Somethin/do-stuff]   💬  ::debug::destination /home/actions/cache/node/12.16.1/x64
[Test Somethin/do-stuff]   💬  ::debug::finished caching tool
[Test Somethin/do-stuff]   ⚙  ::add-path:: /home/actions/cache/node/12.16.1/x64/bin
[Test Somethin/do-stuff]   💬  ::debug::Setting auth in /github/workspace/.npmrc
[Test Somethin/do-stuff]   ⚙  ::set-env:: NPM_CONFIG_USERCONFIG=/github/workspace/.npmrc
[Test Somethin/do-stuff]   ⚙  ::set-env:: NODE_AUTH_TOKEN=XXXXX-XXXXX-XXXXX-XXXXX
[Test Somethin/do-stuff]   ✅  Success - actions/setup-node@v1
[Test Somethin/do-stuff] ⭐  Run Install Dependencies
[Test Somethin/do-stuff]   🐳  docker pull ubuntu:18.04
[Test Somethin/do-stuff]   🐳  docker run image=ubuntu:18.04 entrypoint=[] cmd=["bash" "--noprofile" "--norc" "-eo" "pipefail" "/github/home/.temp-script-262291398"]
[Test Somethin/do-stuff]   ❌  Failure - Install Dependencies
Error: exit with `FAILURE`: 127

In the verbose output the verbose output says npm: command not found which causes the exit.


I thought maybe it was the same issue as #85 but after following @davidalger's steps the output was the same. (I'm also on macOS)

Originally created by @finleygn on GitHub (Feb 20, 2020). Original GitHub issue: https://github.com/nektos/act/issues/86 I've been trying to get my github actions working locally with act (really cool tool btw) but I can't seem to get npm working. Heres an example workflow to show the problem: ``` name: Test Somethin on: pull_request: branches: - develop jobs: do-stuff: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: node-version: 12 registry-url: https://registry.npmjs.org/ - name: Install Dependencies run: npm install env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} ``` Running command `act -j do-stuff -s NPM_TOKEN=XXXX_XXXX_XXXX` I get this output ``` [Test Somethin/do-stuff] ⭐ Run actions/checkout@v2 [Test Somethin/do-stuff] ✅ Success - actions/checkout@v2 [Test Somethin/do-stuff] ⭐ Run actions/setup-node@v1 [Test Somethin/do-stuff] ☁ git clone 'https://github.com/actions/setup-node' # ref=v1 [Test Somethin/do-stuff] 🐳 docker pull node:12-alpine [Test Somethin/do-stuff] 🐳 docker run image=node:12-alpine entrypoint=[] cmd=["node" "/github/home//setup-node985111831/dist/index.js"] [Test Somethin/do-stuff] 💬 ::debug::isExplicit: [Test Somethin/do-stuff] 💬 ::debug::explicit? false [Test Somethin/do-stuff] 💬 ::debug::evaluating 0 versions [Test Somethin/do-stuff] 💬 ::debug::match not found [Test Somethin/do-stuff] 💬 ::debug::evaluating 378 versions [Test Somethin/do-stuff] 💬 ::debug::matched: v12.16.1 [Test Somethin/do-stuff] 💬 ::debug::isExplicit: 12.16.1 [Test Somethin/do-stuff] 💬 ::debug::explicit? true [Test Somethin/do-stuff] 💬 ::debug::checking cache: /home/actions/cache/node/12.16.1/x64 [Test Somethin/do-stuff] 💬 ::debug::not found [Test Somethin/do-stuff] 💬 ::debug::Downloading https://nodejs.org/dist/v12.16.1/node-v12.16.1-linux-x64.tar.gz [Test Somethin/do-stuff] 💬 ::debug::Downloading /home/actions/temp/1a31fd1a-a499-4e30-9d38-531f090e84b2 [Test Somethin/do-stuff] 💬 ::debug::download complete [Test Somethin/do-stuff] 💬 ::debug::Caching tool node 12.16.1 x64 [Test Somethin/do-stuff] 💬 ::debug::source dir: /home/actions/temp/692cf33e-d4ab-4040-a505-f1e4bd026f89/node-v12.16.1-linux-x64 [Test Somethin/do-stuff] 💬 ::debug::destination /home/actions/cache/node/12.16.1/x64 [Test Somethin/do-stuff] 💬 ::debug::finished caching tool [Test Somethin/do-stuff] ⚙ ::add-path:: /home/actions/cache/node/12.16.1/x64/bin [Test Somethin/do-stuff] 💬 ::debug::Setting auth in /github/workspace/.npmrc [Test Somethin/do-stuff] ⚙ ::set-env:: NPM_CONFIG_USERCONFIG=/github/workspace/.npmrc [Test Somethin/do-stuff] ⚙ ::set-env:: NODE_AUTH_TOKEN=XXXXX-XXXXX-XXXXX-XXXXX [Test Somethin/do-stuff] ✅ Success - actions/setup-node@v1 [Test Somethin/do-stuff] ⭐ Run Install Dependencies [Test Somethin/do-stuff] 🐳 docker pull ubuntu:18.04 [Test Somethin/do-stuff] 🐳 docker run image=ubuntu:18.04 entrypoint=[] cmd=["bash" "--noprofile" "--norc" "-eo" "pipefail" "/github/home/.temp-script-262291398"] [Test Somethin/do-stuff] ❌ Failure - Install Dependencies Error: exit with `FAILURE`: 127 ``` In the verbose output the verbose output says `npm: command not found` which causes the exit. --- I thought maybe it was the same issue as #85 but after following @davidalger's steps the output was the same. (I'm also on macOS)
kerem closed this issue 2026-03-01 21:39:30 +03:00
Author
Owner

@fwilhe commented on GitHub (Feb 20, 2020):

Have you tried configuring another image? I had some (limited) success with act -P ubuntu-latest=node:12. Might also depend on if you rely on the default node version or use the setup node action.

I'm wondering about the default home dir /github/workspace. Is this a leftover from the "old" actions? My understanding is that the "new" ones use /home/actions.

<!-- gh-comment-id:589300523 --> @fwilhe commented on GitHub (Feb 20, 2020): Have you tried configuring another image? I had some (limited) success with `act -P ubuntu-latest=node:12`. Might also depend on if you rely on the default node version or use the setup node action. I'm wondering about the default home dir `/github/workspace`. Is this a leftover from the "old" actions? My understanding is that the "new" ones use `/home/actions`.
Author
Owner

@fwilhe commented on GitHub (Feb 20, 2020):

Interesting thing: In this repo https://github.com/SAP/project-piper-action

this job works

  units:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - run: npm ci
    - run: npm test

but this does not

  dist-is-up-to-date:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - run: npm ci
    - run: npm run package
    - run: git diff --name-only --exit-code

It seems to fail in installing packages, I don't understand why.

<!-- gh-comment-id:589302709 --> @fwilhe commented on GitHub (Feb 20, 2020): Interesting thing: In this repo https://github.com/SAP/project-piper-action this job works ``` units: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - run: npm ci - run: npm test ``` but this does not ``` dist-is-up-to-date: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - run: npm ci - run: npm run package - run: git diff --name-only --exit-code ``` It seems to fail in installing packages, I don't understand why.
Author
Owner

@finleygn commented on GitHub (Feb 20, 2020):

If the Github action docs are up to date /github/workspace should be fine
https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#filesystems-on-github-hosted-runners

there was an update to the readme recently (b48a0ef) saying to use the image ubuntu-latest=nektos/act-environments-ubuntu:18.04 so will try that and see how it goes

<!-- gh-comment-id:589335350 --> @finleygn commented on GitHub (Feb 20, 2020): If the Github action docs are up to date `/github/workspace` should be fine https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners#filesystems-on-github-hosted-runners there was an update to the readme recently (b48a0ef) saying to use the image `ubuntu-latest=nektos/act-environments-ubuntu:18.04` so will try that and see how it goes
Author
Owner

@finleygn commented on GitHub (Feb 20, 2020):

image
👏

Thanks for the image idea @fwilhe.

<!-- gh-comment-id:589385340 --> @finleygn commented on GitHub (Feb 20, 2020): ![image](https://user-images.githubusercontent.com/35561611/74986151-e677dd80-5430-11ea-8dc5-ccaf7c0fded2.png) :clap: Thanks for the image idea @fwilhe.
Author
Owner

@finleygn commented on GitHub (Feb 20, 2020):

Although if there is a solution for a more lightweight image that would be cool as the install took about an hour ;-;

<!-- gh-comment-id:589386946 --> @finleygn commented on GitHub (Feb 20, 2020): Although if there is a solution for a more lightweight image that would be cool as the install took about an hour ;-;
Author
Owner

@KingDarBoja commented on GitHub (Feb 20, 2020):

WARNING - this image is >18GB

If you don't have fast internet, this is gonna take way more than 1 hour 😆

<!-- gh-comment-id:589390297 --> @KingDarBoja commented on GitHub (Feb 20, 2020): > **WARNING - this image is >18GB** If you don't have fast internet, this is gonna take way more than 1 hour 😆
Author
Owner

@cplee commented on GitHub (Feb 21, 2020):

I think the issue is actually how I implemented the containers around steps that use actions. There is a separate step used for run steps and uses steps...this means anything you do in the uses step isn't necessarily available in the later run step.

In your case, setup-node installs NodeJS in a separate container from the npm install step.

I'm guessing this is a misunderstanding on my part about how GitHub Actions works...is it your understanding that the uses steps should NOT run in a separate container?

<!-- gh-comment-id:589465882 --> @cplee commented on GitHub (Feb 21, 2020): I think the issue is actually how I implemented the containers around steps that use actions. There is a separate step used for `run` steps and `uses` steps...this means anything you do in the `uses` step isn't necessarily available in the later `run` step. In your case, `setup-node` installs NodeJS in a separate container from the `npm install` step. I'm guessing this is a misunderstanding on my part about how GitHub Actions works...is it your understanding that the `uses` steps should NOT run in a separate container?
Author
Owner

@finleygn commented on GitHub (Feb 21, 2020):

not entirely sure but it was my understanding that uses steps can persist stuff

looking through https://github.com/actions/setup-go it seems like it just interacts directly with the runner?

<!-- gh-comment-id:589562843 --> @finleygn commented on GitHub (Feb 21, 2020): not entirely sure but it was my understanding that uses steps can persist stuff looking through https://github.com/actions/setup-go it seems like it just interacts directly with the runner?
Author
Owner

@cplee commented on GitHub (Feb 21, 2020):

Alright, I have a plan:

  • Each job will get 1 container created and will just use cat for ENTRYPOINT
  • Each step will result in a docker exec into that job container
  • The job container will have a volume created for /github path that will be shared with the one-off containers

What's a one-off container? Some steps will NOT run in the job container:

  • Any step with uses: docker://..... will have a one-off container with the job volume attached
  • Any step with uses: action/name where action/name has an action.yaml with runs.using == 'docker' will have a one-off container with the job volume attached

Will work on this in coming days on branch https://github.com/nektos/act/tree/ISS-86

<!-- gh-comment-id:589746742 --> @cplee commented on GitHub (Feb 21, 2020): Alright, I have a plan: * Each job will get 1 container created and will just use `cat` for `ENTRYPOINT` * Each step will result in a `docker exec` into that job container * The job container will have a volume created for `/github` path that will be shared with the one-off containers What's a one-off container? Some steps will NOT run in the job container: * Any step with `uses: docker://.....` will have a one-off container with the job volume attached * Any step with `uses: action/name` where `action/name` has an action.yaml with `runs.using == 'docker'` will have a one-off container with the job volume attached Will work on this in coming days on branch https://github.com/nektos/act/tree/ISS-86
Author
Owner

@finleygn commented on GitHub (Feb 21, 2020):

looks solid

thanks a bunch :)

<!-- gh-comment-id:589756798 --> @finleygn commented on GitHub (Feb 21, 2020): looks solid thanks a bunch :)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#54
No description provided.