mathieudutour / github-tag-action

A Github Action to automatically bump and tag master, on merge, with the latest SemVer formatted version. Works on any platform.
https://github.com/marketplace/actions/github-tag
MIT License
635 stars 200 forks source link

Error: Cannot find module 'tunnel' #114

Open jhampson-dbre opened 2 years ago

jhampson-dbre commented 2 years ago

Hi o/

We have been using v5 of github-tag-action for a while. Today we tried to update to v6.0 and we are getting this error at the start of the job step:

Run mathieudutour/github-tag-action@v6.0
internal/modules/cjs/loader.js:800
    throw err;
    ^

Error: Cannot find module 'tunnel'
Require stack:
- /opt/tfs/GHE-AR/AR_OPLin_01/_work/_actions/mathieudutour/github-tag-action/v6.0/node_modules/@actions/http-client/index.js
- /opt/tfs/GHE-AR/AR_OPLin_01/_work/_actions/mathieudutour/github-tag-action/v6.0/node_modules/@actions/core/lib/oidc-utils.js
- /opt/tfs/GHE-AR/AR_OPLin_01/_work/_actions/mathieudutour/github-tag-action/v6.0/node_modules/@actions/core/lib/core.js
- /opt/tfs/GHE-AR/AR_OPLin_01/_work/_actions/mathieudutour/github-tag-action/v6.0/lib/main.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 HttpClient._getAgent (/opt/tfs/GHE-AR/AR_OPLin_01/_work/_actions/mathieudutour/github-tag-action/v6.0/node_modules/@actions/http-client/index.js:424:26)
    at HttpClient.getAgent (/opt/tfs/GHE-AR/AR_OPLin_01/_work/_actions/mathieudutour/github-tag-action/v6.0/node_modules/@actions/http-client/index.js:358:21)
    at Object.getProxyAgent (/opt/tfs/GHE-AR/AR_OPLin_01/_work/_actions/mathieudutour/github-tag-action/v6.0/node_modules/@actions/github/lib/internal/utils.js:36:15)
    at Object.<anonymous> (/opt/tfs/GHE-AR/AR_OPLin_01/_work/_actions/mathieudutour/github-tag-action/v6.0/node_modules/@actions/github/lib/utils.js:34:22)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/opt/tfs/GHE-AR/AR_OPLin_01/_work/_actions/mathieudutour/github-tag-action/v6.0/node_modules/@actions/http-client/index.js',
    '/opt/tfs/GHE-AR/AR_OPLin_01/_work/_actions/mathieudutour/github-tag-action/v6.0/node_modules/@actions/core/lib/oidc-utils.js',
    '/opt/tfs/GHE-AR/AR_OPLin_01/_work/_actions/mathieudutour/github-tag-action/v6.0/node_modules/@actions/core/lib/core.js',
    '/opt/tfs/GHE-AR/AR_OPLin_01/_work/_actions/mathieudutour/github-tag-action/v6.0/lib/main.js'
  ]
}

Going back through the release history, it looks like the last release with node_modules/tunnel was v5.3. We retried with v5.3 and we do not get the the Error: Cannot find module 'tunnel' error. It seems like this tunnel dependency just needs to be committed to the repo in newer releases? Not sure why this wouldn't have come up as an issue for other people before now though.

jhampson-dbre commented 2 years ago

I tried running v6.0 on a GitHub-hosted runner and it ran successfully.

Looking at actions/http-client that has tunnel dependency, it looks like it is only referenced when the runner is behind a proxy.

    if (useProxy) {
      // If using proxy, need tunnel
      if (!tunnel) {
        tunnel = require('tunnel')
      }

https://github.com/actions/http-client/blob/18031ad1398f444a83f2c083cf56a2ba81be9ea8/index.ts#L635-L639

The runner where I am getting the Cannot find module 'tunnel' error is on a self-hosted runner behind a proxy, so that explains why this error doesn't always occur. I have tried following the instructions for getting a new release ready to publish by running npm install, and it does add the package under node_modules/tunnel, so I'm not sure why it hasn't been included since v5.3, but it does seem to confirm that adding the package to the release would resolve the issue.