is-ipfs
is-ipfs copied to clipboard
The line const i18n = require('i18next') causes ReferenceError: self is not defined
In an electron app this line :
const i18n = require('i18next');
produces this error message:
yarn start
yarn run v1.22.5
$ cross-env NODE_ENV=development electron-forge start
✔ Checking your system
✔ Locating Application
✔ Preparing native dependencies
✔ Compiling Main Process Code
✔ Launch Dev Servers
⠦ Compiling Preload ScriptsIssues checking in progress...
⠦ Compiling Preload ScriptsIssues checking in progress...
✔ Compiling Preload Scripts
✔ Launching Application
Webpack Output Available: http://localhost:9000
Issues checking in progress...
2021-01-25T09:55:20.639Z info: [meta] logs can be found on /home/marco/.config/IPFSbase
App threw an error during load
ReferenceError: self is not defined
at Object../node_modules/iso-url/src/url-browser.js (/home/marco/webMatters/electronMatters/IPFSbase/.webpack
/main/index.js:44404:21)
at __webpack_require__ (/home/marco/webMatters/electronMatters/IPFSbase/.webpack/main/index.js:21:30)
at Object../node_modules/iso-url/index.js (/home/marco/webMatters/electronMatters/IPFSbase/.webpack
/main/index.js:44342:5)
at __webpack_require__ (/home/marco/webMatters/electronMatters/IPFSbase/.webpack/main/index.js:21:30)
at Object../node_modules/is-ipfs/src/index.js (/home/marco/webMatters/electronMatters/IPFSbase/.webpack
/main/index.js:43618:17)
at __webpack_require__ (/home/marco/webMatters/electronMatters/IPFSbase/.webpack/main/index.js:21:30)
at Object../src/download-cid.js (/home/marco/webMatters/electronMatters/IPFSbase/.webpack/main/index.js:76484:16)
at __webpack_require__ (/home/marco/webMatters/electronMatters/IPFSbase/.webpack/main/index.js:21:30)
at Module../src/main.ts (/home/marco/webMatters/electronMatters/IPFSbase/.webpack/main/index.js:76851:26)
at __webpack_require__ (/home/marco/webMatters/electronMatters/IPFSbase/.webpack/main/index.js:21:30)
A JavaScript error occurred in the main process
Uncaught Exception:
ReferenceError: self is not defined
at Object../node_modules/iso-url/src/url-browser.js (/home/marco/webMatters/electronMatters/IPFSbase/.webpack
/main/index.js:44404:21)
at __webpack_require__ (/home/marco/webMatters/electronMatters/IPFSbase/.webpack/main/index.js:21:30)
at Object../node_modules/iso-url/index.js (/home/marco/webMatters/electronMatters/IPFSbase/.webpack
/main/index.js:44342:5)
at __webpack_require__ (/home/marco/webMatters/electronMatters/IPFSbase/.webpack/main/index.js:21:30)
at Object../node_modules/is-ipfs/src/index.js (/home/marco/webMatters/electronMatters/IPFSbase/.webpack
/main/index.js:43618:17)
at __webpack_require__ (/home/marco/webMatters/electronMatters/IPFSbase/.webpack/main/index.js:21:30)
at Object../src/download-cid.js (/home/marco/webMatters/electronMatters/IPFSbase/.webpack/main/index.js:76484:16)
at __webpack_require__ (/home/marco/webMatters/electronMatters/IPFSbase/.webpack/main/index.js:21:30)
at Module../src/main.ts (/home/marco/webMatters/electronMatters/IPFSbase/.webpack/main/index.js:76851:26)
at __webpack_require__ (/home/marco/webMatters/electronMatters/IPFSbase/.webpack/main/index.js:21:30)
webpack built 9380dd8a3c27d177f76b in 4809ms
in package.json :
devDependencies:
"ipfs-or-gateway": "^2.1.0",
"electron": "^10.1.2",
dependencies:
"ipfs": "^0.53.1",
"ipfs-http-client": "^48.2.0",
"ipfsd-ctl": "^7.2.0",
"is-ipfs": "^2.0.0",
Other info:
- node version: v14.5.0
- O.S. : Ubuntu 18.04.4.Desktop
How to solve the problem?
@hugomrdias does this issue with iso-url in Electron look familiar?
This should not happen, we have tests for Electron. This is probably a webpack config issue, @raphael10-collab you must be bundling with target browser or renderer but running the code in the main thread. Please double check your config.
This module has been refactored and is now ESM only so require can't be used to load it.
Please open a new issue if you're still having problems.