sentry-electron: use v0.5.5 with webpack failed `TypeError: module.require is not a function`
relation #81 .
This problem from #84 .
sentry-electron/dispatch.ts at 326c7a0625f3ae650d390ddd0d667b0da7ea3f99 · getsentry/sentry-electron
use module.require.
But, webpack do not support module.require.
Align module-object to node’s module-object · Issue #20 · webpack/webpack
So, This is failed, below error message.
yarn run v1.7.0
$ cross-env NODE_ENV=development electron .
App threw an error during load
TypeError: module.require is not a function
at new ElectronFrontend (/home/ncaq/Desktop/foo/app/webpack:/node_modules/@sentry/electron/dist/dispatch.js:38:1)
at Object.initAndBind (/home/ncaq/Desktop/foo/app/webpack:/node_modules/@sentry/core/dist/sdk.js:24:1)
at init (/home/ncaq/Desktop/foo/app/webpack:/node_modules/@sentry/electron/dist/sdk.js:51:1)
at Object../src/sentry.js (/home/ncaq/Desktop/foo/app/webpack:/src/sentry.js:3:1)
at __webpack_require__ (/home/ncaq/Desktop/foo/app/webpack:/webpack/bootstrap:19:1)
at Object.<anonymous> (/home/ncaq/Desktop/foo/app/webpack:/src/main.js:18:1)
at Object../src/main.js (/home/ncaq/Desktop/foo/app/main.js:64808:30)
at __webpack_require__ (/home/ncaq/Desktop/foo/app/webpack:/webpack/bootstrap:19:1)
at /home/ncaq/Desktop/foo/app/webpack:/webpack/bootstrap:83:1
at Object.<anonymous> (/home/ncaq/Desktop/foo/app/main.js:87:10)
A JavaScript error occurred in the main process
I try rewrite module.require to dynamic import.
But, module.require in constructor, I can not use await.
I think that should split init to mainInit and rendererInit.
To solve dependend statically.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 23 (1 by maintainers)
I just released
0.15.0; could you guys try the following, if you have this issue instead of importing and usinginitlike:Use
initon the main process with a deep import like:If this works I will write this into the docs.
I temporarily, excluded
@sentry/electronfrom compiling in mywebpack.config.js, here’s the quick fix:Note that now you need to include
@sentry/electronin your application bundle. (e.g. with electron-builder, don’t add it as a dev dependency)Tried this. Not getting the ‘require is not a function’ error anymor but getting this warning during compilation :
Doesn’t prevent the app to start or work… but I’m not getting any error in sentry project though.
Here is my test :
Using Electron 3 and sentry/electron 0.15.0
just use:
Still the same issue with @sentry/electron 0.17.3
I’m having this issue as well. I seem to be having this issue anytime I add Sentry to my Electron package.
FWIW this only happens to me when I run the packaged the app (i.e., the asar), not when I just run it from code. I removed the sentry initialization from the main process, leaving just the render process hooked to sentry for now.
Using webpack 4, sentry/electron 0.12.1, typescript{“target”: “es6”, “moduleResolution”: “node”, “module”: “commonjs”}