Closed sharky98 closed 1 month ago
Question regarding this line 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:174:17
, usually it would be E:\[prj-home]\test-edge-js\edge-js-quick-start\node_modules\edge-js\lib\edge.js:174:17
did you change anything else besides just adapting it to use ESM with import?
When you use unmodified quick-start are modules also resolved that way?
EDIT: If you create a GitHub repo that reproduces the error I could take a look, fork quick-start and add your changes to it.
Yes, this is simply using pnmp
instead of npm
. pnpm
does some linking under the hood, so both path you listed point the same exact file. This is how pnpm
works, so using the quick-start without any modification the module resolve the same way. Basically, it isolate each package, so if you had a dependency on some other package, but not listed in your package.json
, it would fail. But since the quick-start does work as-is, there is something else going on.
I'll do the fork in a bit.
If you can create a GitHub repo forked from quick-start with your changes I will take a look at it.
Here it is :) https://github.com/sharky98/edge-js-quick-start
I did remove the standard, since I am only using Core. But shouldn't change anything (I think?)
Looks like the issue is with edge-js
processing environment variables when you call it this way.
process.env.EDGE_USE_CORECLR = 1;
process.env.EDGE_APP_ROOT = baseNetAppPath;
import { func } from 'edge-js';
process.env.EDGE_APP_ROOT
is not important for Core since all the calls are done specifying assemblyFile: baseDll
but process.env.EDGE_USE_CORECLR = 1;
is not detected.
Running SET EDGE_USE_CORECLR=1
in cmd prompt fixes the issue for that particular cmd window allowing npm run start:module
to execute correctly.
Let me know if that answers your question and whether you found a solution to the problem. I will add ESM example to quick-start if you update your repo with working example.
Closing due to inactivity.
I was playing around with the quick-start. After some issues initially with net8.0 (for some reason, I simply re-did the steps and it worked afterwards 🤷‍♂️), now everything works.
My next step would have been to use ESM with import statements. I simply did the following:
main.js
tomain.mjs
.const path = require('path');
withimport { join } from 'path';
.path
before thepath.join()
calls.var edge = require('edge-js');
withimport { func } from 'edge-js';
.edge
before theedge .func ()
calls.But now edge-js could not load file or assembly 'System.Runtime[...]'.
This is under Node v22.8.0 and dotnet 8.0.401 (runtime 8.0.8).