-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could not dynamically require Microsoft.JavaScript.NodeApi.node in Electron app #264
Comments
Did you try configuring dynamicRequireTargets as the error message suggests? I don't have much experience with Electron, but I understand this is needed to give the bundler a hint about how to locate that Here is the relevant code. I guess if that code were changed to a big series of |
const dotnet = require('node-api-dotnet')
dotnet.System.Console.WriteLine("test") This code executes without a problem. import '../runtime/Microsoft.SemanticKernel'
const dotnet = require('node-api-dotnet')
dotnet.System.Console.WriteLine("test") It was a mistake to join SemanticKernel App threw an error during load |
What JS file is this importing? The code in the |
The problem is related to the bundling/packaging process of Electron, where To work around it, replace this line in -const assemblyName = path.basename(__filename, (__filename.match(/\.[cm]?js$/) || [])[0]);
+const assemblyName = 'Microsoft.SemanticKernel'; We can consider changing the generator tool to output the constant assembly name there instead of using |
Fixed by #303 |
Take a look at #397, I made it work after fixup some paths and use node module's require |
App threw an error during load
Error: Could not dynamically require "D:\code\ai-dotnet-bot\client\dist-electron/win-x64/Microsoft.JavaScript.NodeApi.node". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.
at commonjsRequire (D:\code\ai-dotnet-bot\client\dist-electron\main.js:8:9)
at initialize$1 (D:\code\ai-dotnet-bot\client\dist-electron\main.js:26:22)
at Object. (D:\code\ai-dotnet-bot\client\dist-electron\main.js:34:14)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1311:10)
at Module.load (node:internal/modules/cjs/loader:1098:32)
at Module._load (node:internal/modules/cjs/loader:945:12)
at c._load (node:electron/js2c/node_init:2:13672)
at cjsLoader (node:internal/modules/esm/translators:288:17)
at ModuleWrap. (node:internal/modules/esm/translators:234:7)
The text was updated successfully, but these errors were encountered: