Example in README not working
tlylt opened this issue · 3 comments
Hi there!
I'm trying out the example given in the README, with slight modifications to use the latest actions/checkout
and actions/setup-node
name: "Danger TS"
on: pull_request
permissions:
actions: write
checks: write
contents: write
issues: write
pull-requests: write
statuses: write
jobs:
danger:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: "Use npx to run the dangerfile"
run: "npx danger-ts"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
The result is a CI run failure:
Run npx danger-ts
npm WARN exec The following package was not found and will be installed: danger-ts@1.0.0
node:internal/modules/cjs/loader:998
throw err;
^
Error: Cannot find module '/home/runner/.npm/_npx/d1[7](https://github.com/tlylt/danger-demo/actions/runs/4201699300/jobs/7288964524#step:4:8)13d9723[8](https://github.com/tlylt/danger-demo/actions/runs/4201699300/jobs/7288964524#step:4:9)8ceec/node_modules/lib/node_modules/danger-ts/node_modules/danger/distribution/commands/danger-runner.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:[9](https://github.com/tlylt/danger-demo/actions/runs/4201699300/jobs/7288964524#step:4:10)95:15)
at Function.Module._load (node:internal/modules/cjs/loader:841:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:[12](https://github.com/tlylt/danger-demo/actions/runs/4201699300/jobs/7288964524#step:4:13))
at node:internal/main/run_main_module:22:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Weird, it worked three years ago - maybe see what is being installed in npx via a verbose/debug flag?
Thanks @orta for following up! I just tried adding the --verbose flag, that gave more details from the danger execution:
npx danger-ts --verbose
Node.js v18.14.1
Failing the build, there is 1 fail.
Request failed [403]: https://api.github.com/user
Response: {
"message": "Resource not accessible by integration",
"documentation_url": "https://docs.github.com/rest/reference/users#get-the-authenticated-user"
}
Request failed [403]: https://api.github.com/user
Response: {
"message": "Resource not accessible by integration",
"documentation_url": "https://docs.github.com/rest/reference/users#get-the-authenticated-user"
}
Feedback: https://github.com/tlylt/danger-demo/pull/2#issuecomment-1435437361
Danger: ⅹ Failing the build, there is 1 fail.
## Failures
`node` failed.
## Markdowns
### Log
```sh
This suggests that it could be due to the node version. I found out that v18 and v16 result in the error above. However, v14 still works.
Not too sure what it takes to make it compatible with the latest versions though. Thanks.
Probably that 16 + 18 use different versions of npm and maybe it has different rules (I don't use npm anywhere) maybe there's a way to use yarn to trigger danger ts instead via yarn dlx
which is consistent across builds