ipfs / ipfs/js-ipfs-utils

NodeJS and Electron conflict

Open
#82 4 comments 0 reactions 1 assignee Claimed by @Gozala View on GitHub
kind/enhancement status/ready
Dominant language
JavaScript
Stars
25
Forks
30
PR merge metrics
No merged PRs in 30d

Description

Env:
- Debian Buster
- latest nvm
- latest yarn
- node v15
- latest ipfs-core

I try to use js-ipfs while testing with NodeJS.
As a dependency of ipfs-core, ipfs-utils is installed (dev dependency)
https://github.com/ipfs/js-ipfs-utils/blob/master/src/http/fetch.js

This code check whether or not XMLHttpRequest is available in node and redirect to fetch.browser when available.
However my environment is node and ipfs-utils crashes as fetch.browser requires the global browser fetch.
I could suggest to enhance the initial statement with the following to redirect to fetch.node

```
if (typeof XMLHttpRequest === 'function' && typeof fetch === 'function') {
module.exports = require('./fetch.browser')
```

Thanks

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.