Using the default webpack template, my node native are loaded somewhat like this, using absolute path:
function(e, t, a) {
(function (e) {
try {
global.process.dlopen(e, "D:\\path\\to\my\\repo\\node_modules\\keytar\\build\\Release\\keytar.node")
} catch (e) {
throw new Error("Cannot open D:\\path\\to\my\\repo\\node_modules\\keytar\\build\\Release\\keytar.node: " + e)
}
}
).call(this, a(61)(e))
}
Obviously, it works fine till I blast my node_module folder to oblivion, but as soon as I do, or -more importantly- try to distribute my app, it doesn't work.
In order to debug your problem further, we need a minimal testcase to reproduce your problem. Using create-electron-app --template=webpack as a base, could you please create a minimal Electron app that illustrates the issue you described, and post a link to it here?
Sure, will do, I'll try to provide you with that in the next few days.
On Mon., Jul. 15, 2019, 8:11 p.m. Mark Lee, notifications@github.com
wrote:
In order to debug your problem further, we need a minimal testcase to
reproduce your problem. Using create-electron-app --template=webpack as a
base, could you please create a minimal Electron app that illustrates the
issue you described, and post a link to it here?—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/electron-userland/electron-forge/issues/1029?email_source=notifications&email_token=AC6LESUMFRUAP5KW2N4LFL3P7UG3TA5CNFSM4IDTT4VKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ7J5CY#issuecomment-511614603,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AC6LESVA4PRHHZCLDZ5N7LDP7UG3TANCNFSM4IDTT4VA
.
With the details currently provided, I cannot reproduce the behavior by simply adding the ref native module to a Forge v6 project using Webpack and utilizing it in the main process.
I'll try to reproduce the issue with a minimum reproducible case, maybe
it's only related to keytar specifically, I'll try to look into it asap
On Mon., Jul. 15, 2019, 8:21 p.m. Mark Lee, notifications@github.com
wrote:
With the details currently provided, I cannot reproduce the behavior by
simply adding the ref native module to a Forge v6 project using Webpack.—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/electron-userland/electron-forge/issues/1029?email_source=notifications&email_token=AC6LESWC37PXKRQOGSJ7Z4LP7UIBDA5CNFSM4IDTT4VKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ7KL2I#issuecomment-511616489,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AC6LESQOENRGND7UCUO4S4DP7UIBDANCNFSM4IDTT4VA
.
Here's a MRC. What I did:
create-electron-app --template=webpackyarn add ref keytarmain.js to add some shenanigans with those two native modules.yarn installmain.js)process.resourcesPath+"/"+(-1===__filename.indexOf(".asar")?"app":"app.asar")+"/.webpack/main/native_modules//build/Release/binding.node" Note the double /npm startAfter noticing the issue with the prepare native dep on the make step, I tested this:
npm startnpm run makeCannot open D:\\path\\to\my\\repo\\node_modules\\keytar\\build\\Release\\keytar.node:I noticed that ref.node does not get into the native_modules folder, but keytar.node as well as bindings.node, for what's it worth.
It seems odd to me that keytar is the only native node module impacted, I'll try to reproduce with another
@MarshallOfSound does this have something to do with https://github.com/marshallofsound/webpack-asset-relocator-loader ?
+1
Seems webpack-asset-relocator-loader we are using does not handle it correctly.
Did anyone figure this out? I'm having a similar issue with keytar where everything works until I try to package and run the app on another machine. The binary still points to keytar on the development machine where it was built
+1
The same error as described above
App contains absolute path to keytar of machine that packaged it
OS: Windows
Build using electron-forge and squirrel.windows
Got it work
Changes that I made:
@zeit/webpack-asset-relocator-loader version from 0.5.0 to 0.6.2module.exports = {
entry: './src/index.js',
module: {
rules: [
{
test: /\.(m?js|node)$/,
parser: { amd: false },
use: {
loader: '@zeit/webpack-asset-relocator-loader',
options: {
outputAssetBase: 'assets'
},
},
},
]
}
};
There was module node-loader
And property node: { __dirname: true }
Thanks @shezuka-monkey!! That fixed it for me:
Before
_webpack.rules.js_
module.exports = [
// Add support for native node modules
{
test: /\.node$/,
use: 'node-loader',
},
{
test: /\.(m?js|node)$/,
parser: { amd: false },
use: {
loader: '@marshallofsound/webpack-asset-relocator-loader',
options: {
outputAssetBase: 'native_modules',
},
},
},
];
After
_webpack.rules.js_
module.exports = [
// Add support for native node modules
{
test: /\.(m?js|node)$/,
parser: { amd: false },
use: {
loader: '@marshallofsound/webpack-asset-relocator-loader',
options: {
outputAssetBase: 'native_modules',
},
},
},
];
Most helpful comment
Thanks @shezuka-monkey!! That fixed it for me:
Before
_webpack.rules.js_
After
_webpack.rules.js_