Azure / setup-kubectl

GitHub Action for installing Kubectl
MIT License
132 stars 50 forks source link

Error: Cannot find module '@actions/tool-cache' #41

Closed kurigashvili-godaddy closed 2 years ago

kurigashvili-godaddy commented 2 years ago

I am getting the following error:

Run azure/setup-kubectl@fe45ba1148dde192f0ccd6dbb58caacb996c1452
internal/modules/cjs/loader.js:800
    throw err;
    ^

Error: Cannot find module '@actions/tool-cache'
Require stack:
- /usr/local/bin/actions-runner/_work/_actions/azure/setup-kubectl/fe45ba1148dde192f0ccd6dbb58caacb996c1452/lib/run.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
    at Function.Module._load (internal/modules/cjs/loader.js:690:27)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/usr/local/bin/actions-runner/_work/_actions/azure/setup-kubectl/fe45ba1148dde192f0ccd6dbb58caacb996c1452/lib/run.js:16:19)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/local/bin/actions-runner/_work/_actions/azure/setup-kubectl/fe45ba1148dde192f0ccd6dbb58caacb996c1452/lib/run.js'
  ]
}

I am confused if I need install those modules separately. I am using self hosted runners.

My understanding all dependencies should be pre-build using ncc package (recommended approach from Github)

https://docs.github.com/en/actions/creating-actions/creating-a-javascript-action#commit-tag-and-push-your-action-to-github

Example: https://github.com/actions/setup-node/blob/main/package.json#L8 https://github.com/actions/setup-node/blob/main/dist/setup/index.js

qpetraroia commented 2 years ago

Hey @kurigashvili-godaddy,

Everything should be bundled properly. Is it possible to get any information on your runner? We are wondering if that is causing the issue.

kurigashvili-godaddy commented 2 years ago

@qpetraroia it is a self hosted runner: Amazon Linux 2 EC2. May be the npm packages that you are relying are preinstalled on Github hosted runners. The recommended approach is to pre-build using ncc package and commit the build output to the repo. This is how Github does for all their official actions that require extra dependencies.

github-actions[bot] commented 2 years ago

This issue is idle because it has been open for 14 days with no activity.

OliverMKing commented 2 years ago

We just published a new release that resolves this.