agracio/electron-edge-js

I use electron v3.0.10 and node.js v10.2.0 and electron-edge-js have a problem about edge_nativeclr

zxy-mapper opened this issue · 17 comments

image

this is my code
image

image

I hope to get your help

thanks

I have the same issue under Node 10.11 and Electron 4.0.5. I just installed electron-edge-js and tried to do a "Hello World" test (about the same as OP) and got exactly the same error

EDIT : same error with electron 4.0.4 and 4.0.3

Similar issue running Electron 4.1.1, Node 10.15.3, and Angular 7
Error I get is:

Cannot find module Uncaught Error: Cannot find module '....\App\node_modules\electron\dist\resources\electron.asar\renderer\native\win32\x64\10.11.0\edge_nativeclr'
    at webpackEmptyContext (lib sync:2)
    at Object../node_modules/electron-edge-js/lib/edge.js (edge.js:59)
    at __webpack_require__ (bootstrap:78)
    at Module../src/app/pages/home/home.component.ts (main.js:4027)
    at __webpack_require__ (bootstrap:78)
    at Module../src/app/app-routing.module.ts (main.js:3447)
    at __webpack_require__ (bootstrap:78)
    at Module../src/app/app.module.ts (app.component.ts:15)
    at __webpack_require__ (bootstrap:78)
    at Module../src/main.ts (main.ts:1)

I'm using angular as well, and I think in my case it might have something to do with that.
I can run the sample repo fine, using the same versions as above.
I can run my own app fine if I run it with electron . but the angular stuff doesn't load.
However if I run it so the angular stuff does load, I get the above error, presumably because the edge files haven't been built to the right place?

My package.json file for reference: https://gist.github.com/tbeswick96/798a5d07bfede1197b65d097ed0b4e95

You need to prevent electron-edje-js from beein packed into the .asar file, you cannot load native node modules from it.

@tbeswick96 config for example he uses electron-builder so he need to exclude electron-edje-js from the asar packing by defining the asarUnpack config https://www.electron.build/configuration/configuration#Configuration-asar

@Hammster Added "asarUnpack": "*.+(node|dll)" to my electron-builder.json, but still the same error.
This occurs when I am not packing it with electron-builder, i.e running locally for development
I haven't tried making a release build as it needs to work in development first

Take a look at this example for packaging Electron with electron-edge-js: https://github.com/zenb/electron-edge-js-quick-start. This is based of original quickstart provided for this repo: https://github.com/agracio/electron-edge-js-quick-start

That's useful, thanks, but that doesn't help the main issue which is running this with angular.
I'm not trying to run an electron-builder build, i'm running it locally with npm start, and I get the error.
The edge part works when I run npm run electron . but I get none of the angular interface
The angular interface works when I run npm start, but I get the edge error

It depends what npm start does in your project, as you can see from error message it is trying to find parts of electron-edge-js inside asar archive. You need to figure out what is executed when you run npm start and what needs to be done to make it work for both Angular and electron-edge-js.
EDIT: as @Hammster notes, you needs to prevent asar packaging for Edge.js meaning something in your script does perform packaging, likely electron-builder.

I have managed to get it working. Managed to find a working example out there that had all three components (electron, angular, and edge) and copied how it laid things out.
For reference: https://github.com/bill-long/EventLogExpert
It works both running locally, and packaged with electron-builder

I think the error message I was getting was misleading, as I think it was actually my own dll location that was failing. Not certain

@ApologizeAndStruggle @QBIRGAENTZLE I'd recommend trying to find an existing application out there with a similar setup to yours, and then copy the essential bits from that (like package.json) and see if that helps

is0xb commented

I have the same problem
Error: Cannot find module 'project_root\dist_electron\native\win32\x64\12.4.0\edge_nativeclr'
Electron v6.1.0
Node v12.4.0
vue/cli 4.0.4
windows 10 1903 x64

I have the same issue:
image
Electron v6.1.5
Node v12.4.0
vue/cli 4.0.5
electron-edge-js v12.4.1
windows 10 x64.
The error occurs when I require the electron-edge-js module.
var edge = require('electron-edge-js');
Note: This happens in development, not packaging.

I have the same issue:
image
Electron v6.1.5
Node v12.4.0
vue/cli 4.0.5
electron-edge-js v12.4.1
windows 10 x64.
The error occurs when I require the electron-edge-js module.
var edge = require('electron-edge-js');
Note: This happens in development, not packaging.

the same question,I will be carzy

Hey, guys.
I had the same problem.
I decided to add extra parameters in the webpack configuration for the rendering process and it worked for me:

...
  externals: {
    'electron-edge-js': 'commonjs2 electron-edge-js',
  },
  node: {
    __dirname: false,
    __filename: false,
  },
...

To clear up my doubts, I ran the electro-quick-start project without a webpack and it worked, so I researched a configuration to discard the electron-edge-js of the build process.
In my case the bad configured webpack that generated this bug.

Does @akozhemiakin help you?

@lesleyandreza
I'm a little bit confused, is it a question to me or to someone I should have helped?) If it is a question to me, would you mind to clarify it a little bit)

Sorry @akozhemiakin.
I wish I had marked the creator of this issue @zxy-mapper.

In our case this error happened on Windows 7 machine (without service pack 1)
The path of edge_nativeclr.node on error message is correct, it does exist. but I can't figure out the reason of the error.
It seems like the electron-edge-js's required package Microsoft Visual C++ 2015 Redistributable (x86) is not support on Windows 7.
When I tried to install C++ 2015 I got error 0x80240017, which is solved by (as I read on Internet) updating windows.
However, it seems like Windows 7 update service is no longer available because on Windows 7 (with and without SP1) machines when I run windows update I got following error: 80072EFE.

Apparently the minimum requirement is Windows 7 Service Pack 1.
Also, in our case we also needed .NET Framework 4.7 for our app which also requires SP1. Installing .NET 4.7 on machine which is not up to date also requires some manual work, because as I already said Windows updates does not work.

This error was gone when we used Windows 7 SP1 and installed Microsoft Visual C++ 2015 Redistributable (x86) and .NET 4.7 Framework

I have the same question,when i use the electron 11,node 12.18.3,electron-edge-js 12.18.5
I read the document about 'electron-edge-js',it supported the version i use
maybe this question was caused by webpack compile,but i use 'vue-cli-plugin-eletron-builder' with the externals attribute, also wrong
who has some suggests form me? thanks a lot
image