Troubleshooting tips: TypeError: func.apply is not a function #625

Closed
opened 2025-08-09 17:17:01 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @tomasaschan on 6/28/2017

I'm getting a System.Exception: Call to Node module failed with error: TypeError: func.apply is not a function when trying to do some simple hello world stuff, and I'm not sure how to troubleshoot. I've tried to follow the guide in the readme and apply it to my application, but without success.

Here's my code:

serverside-renderer.build.js, produced by webpack and present in the project root:

/* some webpack bootstrapping omitted */
module.exports = function (callback) { // same result with export default
    var result = '<p>hello from node!</p>';

    callback( /*error*/null, result);
};

MyView.cshtml:

@using Microsoft.AspNetCore.NodeServices
@inject INodeServices Node
@await Node.RenderReactApplication() // same result when waiting synchronously with .Result

NodeServicesExtensions.cs:

public static class NodeServicesExtensions
{
    public static async Task<IHtmlContent> RenderReactApplication<T>(this INodeServices services, string path, T model)
    {
        var renderedApp = await services.InvokeAsync<string>("./serverside-renderer.build");
        return new StringHtmlContent(renderedApp);
    }
}

Am I missing something trivial here? How do I troubleshoot?

*Originally created by @tomasaschan on 6/28/2017* I'm getting a `System.Exception: Call to Node module failed with error: TypeError: func.apply is not a function` when trying to do some simple hello world stuff, and I'm not sure how to troubleshoot. I've tried to follow the guide in the readme and apply it to my application, but without success. Here's my code: `serverside-renderer.build.js`, produced by webpack and present in the project root: ``` /* some webpack bootstrapping omitted */ module.exports = function (callback) { // same result with export default var result = '<p>hello from node!</p>'; callback( /*error*/null, result); }; ``` `MyView.cshtml`: ``` @using Microsoft.AspNetCore.NodeServices @inject INodeServices Node @await Node.RenderReactApplication() // same result when waiting synchronously with .Result ``` `NodeServicesExtensions.cs`: ``` public static class NodeServicesExtensions { public static async Task<IHtmlContent> RenderReactApplication<T>(this INodeServices services, string path, T model) { var renderedApp = await services.InvokeAsync<string>("./serverside-renderer.build"); return new StringHtmlContent(renderedApp); } } ``` Am I missing something trivial here? How do I troubleshoot?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#625
No description provided.