agracio / edge-js

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

Having Dotnet and NodeJS project not-colocated? #219

Closed sharky98 closed 1 month ago

sharky98 commented 1 month ago

I see in the quick-start, that the csproj file have a reference to the DLL inside the node_modules folder. However, in my case I would not have NodeJS inside the same project, so I wouldn't have access to that file. I was expecting to create a project, build and publish it then move the published DLL (with all its referenced DLL) near my NodeJS project and simply create a PackageReference to the nuget package EdgeJs. However it doesn't work, even in the quick-start.

Replacing this

<ItemGroup>
  <Reference Include="EdgeJs">
    <HintPath>..\..\node_modules\edge-js\lib\bootstrap\bin\Release\EdgeJs.dll</HintPath>
  </Reference>
</ItemGroup>

With that

<ItemGroup>
  <PackageReference Include="EdgeJs" Version="20.12.3" />
</ItemGroup>

Result in the following error.

node:internal/modules/cjs/loader:1717
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^
Error: Call to coreclr_create_delegate() for G failed with a return code of 0x80070002.
    at Module._extensions..node (node:internal/modules/cjs/loader:1717:18)
    at Module.load (node:internal/modules/cjs/loader:1317:32)
    at Module._load (node:internal/modules/cjs/loader:1127:12)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)
    at require (node:internal/modules/helpers:135:16)
    at Object.<anonymous> (E:\[prj-home]\test-edge-js\edge-js-quick-start\node_modules\.pnpm\edge-js@22.7.0\node_modules\edge-js\lib\edge.js:49:8)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
agracio commented 1 month ago
<ItemGroup>
  <Reference Include="EdgeJs">
    <HintPath>..\..\node_modules\edge-js\lib\bootstrap\bin\Release\EdgeJs.dll</HintPath>
  </Reference>
</ItemGroup>

Is correct, once you build your project all dlls including EdgeJs.dll are copied to your output folder in case of quick-start it would be in edge-js-quick-start\src\QuickStart.Core\bin\Debug\net7.0. That is the folder you would include in your published application in case of quick-start.

<ItemGroup>
  <PackageReference Include="EdgeJs" Version="20.12.3" />
</ItemGroup>

Is referring to a completely different use case where you are calling Node.js from C#.

agracio commented 1 month ago

Closing due to inactivity.