denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
95.48k stars 5.3k forks source link

Edge.js - Uncaught TypeError: LoadLibraryExW failed #25868

Open HeyITGuyFixIt opened 2 weeks ago

HeyITGuyFixIt commented 2 weeks ago

Version: deno 2.0.0-rc.5+8cdb309 (canary, release, x86_64-pc-windows-msvc) v8 12.9.202.13-rusty typescript 5.6.2 npm:edge-js@22.7.0

PS > deno install --allow-scripts npm:edge-js@22.7.0
Add npm:edge-js@22.7.0
  Determining projects to restore...
  Restored C:\Users\Christian Sirolli\Documents\Projects\edgejsrepr\node_modules\.deno\edge-js@22.7.0\node_modules\edge-js\lib\bootstrap\bootstrap.csproj (in 641 ms).
  Restored C:\Users\Christian Sirolli\Documents\Projects\edgejsrepr\node_modules\.deno\edge-js@22.7.0\node_modules\edge-js\src\double\Edge.js\Edge.js.csproj (in 641 ms).
  Determining projects to restore...
  All projects are up-to-date for restore.
  Edge.js -> C:\Users\Christian Sirolli\Documents\Projects\edgejsrepr\node_modules\.deno\edge-js@22.7.0\node_modules\edge-js\src\double\Edge.js\bin\Release\net6.0\EdgeJs.dll
  bootstrap -> C:\Users\Christian Sirolli\Documents\Projects\edgejsrepr\node_modules\.deno\edge-js@22.7.0\node_modules\edge-js\lib\bootstrap\bin\Release\bootstrap.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:03.35
***************************************
TypeError: LoadLibraryExW failed
    at Object.Module._extensions..node (node:module:797:20)
    at Module.load (node:module:665:32)
    at Function.Module._load (node:module:537:12)
    at Module.require (node:module:684:19)
    at require (node:module:808:16)
    at Object.<anonymous> (file:///C:/Users/Christian Sirolli/Documents/Projects/edgejsrepr/node_modules/.deno/edge-js@22.7.0/node_modules/edge-js/lib/edge.js:49:8)
    at Object.<anonymous> (file:///C:/Users/Christian Sirolli/Documents/Projects/edgejsrepr/node_modules/.deno/edge-js@22.7.0/node_modules/edge-js/lib/edge.js:177:4)
    at Module._compile (node:module:748:34)
    at Object.Module._extensions..js (node:module:767:10)
    at Module.load (node:module:665:32)
***************************************
Success: platform check for edge.js: node.js x64 v20.11.1

In Deno's REPL:

> import edge from 'npm:edge-js@22.7.0';
Uncaught TypeError: LoadLibraryExW failed
    at Object.Module._extensions..node (node:module:797:20)
    at Module.load (node:module:665:32)
    at Function.Module._load (node:module:537:12)
    at Module.require (node:module:684:19)
    at require (node:module:808:16)
    at Object.<anonymous> (file:///C:/Users/Christian Sirolli/Documents/Projects/edgejsrepr/node_modules/.deno/edge-js@22.7.0/node_modules/edge-js/lib/edge.js:49:8)
    at Object.<anonymous> (file:///C:/Users/Christian Sirolli/Documents/Projects/edgejsrepr/node_modules/.deno/edge-js@22.7.0/node_modules/edge-js/lib/edge.js:177:4)
    at Module._compile (node:module:748:34)
    at Object.Module._extensions..js (node:module:767:10)
    at Module.load (node:module:665:32)

I tried this with deno v1.46.3, v2.0.0-rc.5 (rc), and 2.0.0-rc.5+8cdb309 (canary). I have "nodeModulesDir": "auto" in my deno.json file.

I have seen a few issues and some merged PRs that are related to "LoadLibraryExW failed". Does it look like I'm missing something or is there a limitation in Deno, or maybe there is something that Edge.js can do to add Deno support?

nathanwhit commented 2 weeks ago

I believe the issue is that edge-js is a node addon that uses Node.JS and V8's APIs directly (e.g. https://nodejs.org/api/addons.html#c-addons) which are not ABI stable and deno does not support.

The addon would have to use exclusively napi (https://nodejs.org/api/n-api.html), which is ABI stable, for deno to support it. This would have the added benefit of being guaranteed to work across Node major versions with a single addon, instead of having separate addons for each node major version.


The LoadLibraryExW error occurs upon trying to load the addon because it has dependencies on dynamic libraries that are not present.

HeyITGuyFixIt commented 2 weeks ago

Would it be possible for Deno to support those APIs? Then addons could have a build for Deno, without rewriting it to be ABI stable, as an option.

lucacasonato commented 2 weeks ago

No, they rely on the internals of Node.js. They can break at any time, even in Node.js, whenever Node.js changes anything about it's internals.