danger / swift

⚠️ Stop saying "you forgot to …" in code review
https://danger.systems/swift/
MIT License
1.04k stars 135 forks source link

ReferenceError: fetch is not defined on MacOS #608

Closed SvenMuc closed 1 month ago

SvenMuc commented 2 months ago

I installed danger-swift with homebrew on my MacBookPro M3.

When I run e.g. danger-swift pr https://xxx/merge_requests/300 I receive the following error message. The same error message appears in my Gitlab based CI pipeline with danger-swift ci --remove-previous-comments --verbose --trace-warnings

Any ideas what's going wrong?

Error:  ReferenceError: fetch is not defined
    at defaultRequestHandler (/snapshot/danger-js/node_modules/@gitbeaker/rest/dist/index.js:101:22)
    at Object.requester.<computed> [as get] (/snapshot/danger-js/node_modules/@gitbeaker/requester-utils/dist/index.js:53:16)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at process.runNextTicks [as _tickCallback] (node:internal/process/task_queues:65:3)
    at Function.runMain (pkg/prelude/bootstrap.js:1980:13)
    at node:internal/main/run_main_module:17:47
    at async /snapshot/danger-js/node_modules/@gitbeaker/core/dist/index.js:105:22

I also tested again the public repo mentioned in Getting Started with Danger - Test Locally. Same issue. Seems it has to do something with my macOS setup.

danger-swift pr https://github.com/danger/swift/pull/146

orta commented 2 months ago

Not sure how you control your instance of Node - but it will need updating to get rid of this issue

SvenMuc commented 2 months ago

@orta I haven't installed Node at all. I just installed danger globally as I did it on my old MacBook a year ago. I followed these instructions.

https://danger.systems/swift/guides/getting_started#homebrew

I also tried to install latest node version vie brew. But without any effect.

I just saw at danger-js that there was a major release change in the node engine. Does danger-swift relies on danger-js?

https://github.com/danger/danger-js/releases

Jeepston commented 1 month ago

Having the same issue on remote gitlab runner. Everything is managed by brew there. Node version is 22.2

hujunfeng commented 1 month ago

Same issue when running danger-swift pr.

> node --version
v22.2.0
> which node
/opt/homebrew/bin/node
> danger-swift --version
3.18.1
> which danger-swift
/opt/homebrew/bin/danger-swift
SvenMuc commented 1 month ago

The issue has been solved by https://github.com/danger/danger-js/issues/1448