actions / runner-container-hooks

Runner Container Hooks for GitHub Actions
MIT License
67 stars 43 forks source link

Cannot find module 'hooklib' when building #92

Closed daniestevez closed 1 year ago

daniestevez commented 1 year ago

I'm trying to build this as indicated here, and I'm getting the error:

src/hooks/prepare-job.ts:4:67 - error TS2307: Cannot find module 'hooklib' or its corresponding type declarations.

I'm using Debian 12 with npm installed with apt.

I've run git clone https://github.com/actions/runner-container-hooks; cd runner-container-hooks; git checkout v0.3.2 and then:

:~/runner-container-hooks$ npm install && npm run bootstrap && npm run build-all

added 215 packages, and audited 216 packages in 7s

68 packages are looking for funding
  run `npm fund` for details

2 moderate severity vulnerabilities

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

> hooks@0.3.2 bootstrap
> npm install --prefix packages/hooklib && npm install --prefix packages/k8s && npm install --prefix packages/docker

npm WARN deprecated @zeit/ncc@0.22.3: @zeit/ncc is no longer maintained. Please use @vercel/ncc instead.

added 209 packages, and audited 210 packages in 7s

64 packages are looking for funding
  run `npm fund` for details

2 moderate severity vulnerabilities

To address all issues, run:
  npm audit fix

Run `npm audit` for details.
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142

added 413 packages, and audited 414 packages in 11s

31 packages are looking for funding
  run `npm fund` for details

5 moderate severity vulnerabilities

To address issues that do not require attention, run:
  npm audit fix

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.

added 434 packages, and audited 435 packages in 10s

44 packages are looking for funding
  run `npm fund` for details

3 moderate severity vulnerabilities

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

> hooks@0.3.2 build-all
> npm run build --prefix packages/hooklib && npm run build --prefix packages/k8s && npm run build --prefix packages/docker

> hooklib@0.1.0 build
> tsc

> kubehooks@0.1.0 build
> tsc && npx ncc build

src/hooks/prepare-job.ts:4:67 - error TS2307: Cannot find module 'hooklib' or its corresponding type declarations.

4 import { ContextPorts, prepareJobArgs, writeToResponseFile } from 'hooklib'
                                                                    ~~~~~~~~~

src/hooks/run-container-step.ts:3:38 - error TS2307: Cannot find module 'hooklib' or its corresponding type declarations.

3 import { RunContainerStepArgs } from 'hooklib'
                                       ~~~~~~~~~

src/hooks/run-script-step.ts:3:35 - error TS2307: Cannot find module 'hooklib' or its corresponding type declarations.

3 import { RunScriptStepArgs } from 'hooklib'
                                    ~~~~~~~~~

src/index.ts:2:60 - error TS2307: Cannot find module 'hooklib' or its corresponding type declarations.

2 import { Command, getInputFromStdin, prepareJobArgs } from 'hooklib'
                                                             ~~~~~~~~~

src/k8s/index.ts:3:41 - error TS2307: Cannot find module 'hooklib' or its corresponding type declarations.

3 import { ContainerInfo, Registry } from 'hooklib'
                                          ~~~~~~~~~

src/k8s/utils.ts:3:23 - error TS2307: Cannot find module 'hooklib' or its corresponding type declarations.

3 import { Mount } from 'hooklib'
                        ~~~~~~~~~

Found 6 errors in 6 files.

Errors  Files
     1  src/hooks/prepare-job.ts:4
     1  src/hooks/run-container-step.ts:3
     1  src/hooks/run-script-step.ts:3
     1  src/index.ts:2
     1  src/k8s/index.ts:3
     1  src/k8s/utils.ts:3
nikola-jokic commented 1 year ago

Hey @daniestevez,

I was able to reproduce the issue, but I am not sure why it is happening. The way I fixed it is to cd to the hook that you want to build, rm -rf package-lock.json && rm -rf node_modules && npm cache clean --force && npm i && npm run build

I also tried running it on Ubuntu, but it worked.

nikola-jokic commented 1 year ago

Since this is likely a bug in npm, not really the hook, I will close it here.