Skip to content

Jering.Javascript.NodeJS.InvocationException - resolvedPath.replaceAll is not a function #192

@Orh1989

Description

@Orh1989

Hi,
I try to use the API for InvokeFromFileAsync but I recieve the following exception:

Message = "resolvedPath.replaceAll is not a function\nTypeError: resolvedPath.replaceAll is not a function\n at IncomingMessage. (file:///C:/Users/user/source/repos/ConsoleApp1/ConsoleApp2/bin/Debug/net6.0/[eval1]:178:58)\n at IncomingMessage.emit (events.js:412:35)\n at endReadableNT (internal/streams/readable.js:1334:12)\n at processTicksAndRejections (internal/process/task_queues.js:82:21)"

It occurs for my .js file (which using 3rd party js library) so I tested the example from readme, but same error:

start.js
module.exports = (callback, message) => callback(null, { resultMessage: message });

C# code is

var services = new ServiceCollection();
services.AddNodeJS();
ServiceProvider serviceProvider = services.BuildServiceProvider();
INodeJSService nodeJSService = serviceProvider.GetRequiredService<INodeJSService>();
string scriptPath = @"C:\Users\user\Desktop\enc\start.js";
var result = await nodeJSService.InvokeFromFileAsync<Result>(scriptPath, args: new[] { "success" });

The exception thrown on the calling to InvokeFromFileAsync

The original JS code was

var package = require('some-installed-package');

function test(param){
	return package.someMethod(param)
}
module.exports = {
	test: test
}

var result = await nodeJSService.InvokeFromFileAsync<Result>(scriptPath, "test", args: new[] { "success" });

Not sure what I've missed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions