agracio / edge-js

Run .NET and Node.js code in-process on Windows, macOS, and Linux
MIT License
618 stars 93 forks source link

Edge-js: Uncaught Error: The specified procedure could not be found. \\? ... \edge_nativeclr.node #208

Closed JDP124 closed 3 months ago

JDP124 commented 3 months ago

Hi I wondered if you could take a look at the below, it seems I can't get Edge-js to run in my project.

I’m trying to use edge-js to run a .NET dll in a Typescript vscode LSP extension I’m working on. I have a local seperate Typescript project that successfully runs the dll using Edge-js. But can’t seem to get Edge-js to run because of this error:

adding a reference to edge.func() const method = edge.func(filename); edge.func("");

raises this error: Uncaught Error Error: The specified procedure could not be found. \?\c:{path to project}\node_modules\edge-js\lib\native\win32\x64\18.19.1\edge_nativeclr.node at func (electron/js2c/node_init:2:2214) at Module._extensions..node (internal/modules/cjs/loader:1356:18) at func (electron/js2c/node_init:2:2214) at Module.load (internal/modules/cjs/loader:1126:32) at Module._load (internal/modules/cjs/loader:967:12) at c._load (electron/js2c/node_init:2:13672) at Module.require (internal/modules/cjs/loader:1150:19) at require (internal/modules/cjs/helpers:119:18) at (c:\VisualfilesSrc\V6.X\VSCScriptEditor\node_modules\edge-js\lib\edge.js:53:8) at Module._compile (internal/modules/cjs/loader:1271:14) at Module._extensions..js (internal/modules/cjs/loader:1326:10) at Module.load (internal/modules/cjs/loader:1126:32) at Module._load (internal/modules/cjs/loader:967:12) at c._load (electron/js2c/node_init:2:13672) at Module.require (internal/modules/cjs/loader:1150:19) at require (internal/modules/cjs/helpers:119:18) at (c:\VisualfilesSrc\V6.X\VSCScriptEditor\server\src\server.ts:47:1) at Module._compile (internal/modules/cjs/loader:1271:14) at Module._extensions..js (internal/modules/cjs/loader:1326:10) at Module.load (internal/modules/cjs/loader:1126:32) at Module._load (internal/modules/cjs/loader:967:12) at c._load (electron/js2c/node_init:2:13672) at executeUserEntryPoint (internal/modules/run_main:101:12) at (internal/main/run_main_module:23:47)

The node module is indeed where it should be.

Node version : v20.11.0 I have tried Edge-js v21.7.2 and v22.1.1

The closest thing I could find online is this: Error: The specified module could not be found but this error is module not found, mine is procedure not found, not sure if relevant.

Looking into Edge.js file it seems the project is using Node v18.18.2, not sure if this is relevant, but my Typescript project that does run Edge-js without issue shows its running v20.11.0

determineVersion() = 18.19.1 process.versions.node = 18.18.2

Thanks in advance for any assistance

agracio commented 3 months ago

From the error it is looking for module in \?\c:{path to project}\node_modules\edge-js\lib\native\win32\x64\18.19.1\edge_nativeclr.node path which is incorrect. Could it have something to do with module packaging for VS Code? c:\VisualfilesSrc\V6.X\VSCScriptEditor\node_modules\edge-js\lib\edge.js in error stack trace resolves to path without artefacts which is rather strange. When using Node.js native modules in VS Code plugins do they have to be compiled to Node.js version or Electron version? From what I can see in some GitHub issues it should be compiled as Electron native module, process.versions.node = 18.18.2 indicates Electron v28 try electron-edge-js instead.

Take a look at this answer: https://github.com/microsoft/vscode/issues/658#issuecomment-159859624 and a couple below it. In you case you don't need to do any of that since electron-edge-js comes precompiled with correct headers, just make sure that path resolution for native module is correct.

EDIT: electron-edge-js does not support running in console, you would need to modify your test project to run Electron instead. https://github.com/agracio/electron-edge-js-quick-start

JDP124 commented 3 months ago

Amazing, electron-edge-js runs. thank you.