-
-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Import the .node file in the main process and report an error #1302
Comments
Can you please share the |
|
This is the same issue I'm having with https://www.npmjs.com/package/sack.vfs. (on windows) found this related issue: #610
the background.js just has
It would be nice if .node files could just be used without any extra work... is this just because it's background and not main? Also - if the .node had additional .DLLs associated with it, don't suppose those would be automatically included? Edit: the current published version has additional issues with OpenSSL and Electron, and being rebuilt; there is an in-dev branch that works better; but still, the binary .node file isn't actually figured out. Edit2: main.js and background.js behave the same way; so it's not just a background issue. I do wonder still if there's a Linux ELF/Windows PE detection issue... that a .node that's also PE doesn't work? |
The template repository you shared has some other issues with it that will cause an error, but to load the .node file in the main process you should add this to your // this goes inside of module.exports = {
pluginOptions: {
electronBuilder: {
nodeIntegration: true,
chainWebpackMainProcess(config) {
config.module
.rule("node")
.test(/\.node$/)
.use("native-ext-loader")
.loader("native-ext-loader")
.options(
process.env.NODE_ENV === "development"
? {
rewritePath: path.resolve(__dirname, "native"),
}
: {}
)
},
},
} Your existing config only effected the renderer process, so it would work if you are importing the module into |
Describe the bug
`
error in ./native/index.node
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
@ ./src/background.js 15:0-44 16:12-21
@ multi ./src/background.js
`
Screenshots
Environment (please complete the following information):
"electron": "^9.0.0",
"electron-build-env": "^0.2.0",
"vue": "^2.6.11",
"native-ext-loader": "^2.3.0",
"neon-cli": "^0.6.0",
"vue-cli-plugin-electron-builder": "~2.0.0-rc.5",
The text was updated successfully, but these errors were encountered: