-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Need a way to manually config IPFS to run in 'browser mode'. #1259
Comments
js-ipfs will use IndexedDB in the browser. You need to "bundle" your code before using the browser process or just use the dist version of js-ipfs. See also ipfs/notes#256 |
I'm using create-react-app, and load localhost:3000 into electron's renderer process. I think create-react-app has bundled my code. If you clone https://github.com/linonetwo/pants-control and |
Can you release a |
@linonetwo note that using a script tag will not add From the README: See this example: https://github.com/ipfs/js-ipfs/blob/master/examples/browser-script-tag/index.html To solve any other issues int he future, I advise you to webpack/rollup/browserify any code that goes into your renderer process, it is very common for npm packages to have "browser dependencies" that only get injected in the step of "bundling for the browser". This will bite you again if you don't. |
Thank you! I was too careless to found this case sensitive variable. Now application runs both on the renderer process and browser. And thanks for your advice. I actually bundled my code and it's an independent web page, but you remind me that in my npm script there is a // Make it run in electron renderer process
// If we want electron start, we will set cross-env BROWSER=none
if (process.env.BROWSER === 'none') {
delete config.node;
config.target = 'electron-renderer';
} So when I bundled my web page for the renderer process, Problem solved, closing this! |
Glad it all worked :D 🎉 |
Version: 0.28.1
Platform: Mac
Type: Enhancement
Severity: Medium
Description:
The code:
is ambiguous.
In browser environment it will create an in memory repo (I guess, since nothing created in the fs), but in electron renderer process it will create a repo folder in the fs:

And in electron renderer process I can't simply
import IPFS from 'ipfs'
, since this will causeCan't resolve './build/Release/fs-ext'
.I can only
const IPFS = require('electron').remote.require('ipfs');
, and this will create a repo in the fs.I think the reason is that IPFS is now in 'nodeJS mode', not the 'browser mode' I need.
I wonder if there is a way to manually config IPFS to run in 'browser mode'.
Steps to reproduce the error:
clone https://github.com/linonetwo/pants-control , run
yarn
andyarn start
.The text was updated successfully, but these errors were encountered: