How to fix: Error: If .NET source is provided as JavaScript function, function body must be a /* ... */ comment

419 views Asked by At

I am trying to run the basic hello world example from the documentation from here (it's the first example on the page): https://github.com/agracio/edge-js

I have a typescript file that I am running (see the code below). I am on node version 9.9.0 on a Windows 10 64 bit. I have made only the following installations: npm install edge npm install edge.js npm install @types/node --save-dev

I have made the installations to the same directory as the typescript file.

I am able to run ts-node app.ts in the command line and have it console.log("hi") successfully in that directory.

However, when I change my code to the example below, it is giving me the error throw new Error('If .NET source is provided as JavaScript function, function body must be a /* ... */ comment.');

I had originally tried doing this using edge.js but I kept getting the error that I needed to precompile. For the life of me I couldn't get it to find my python executable when executing build.bat release 10.5.3. (Despite including an environment variable PYTHON with a value of c:\Python\Python37\python.exe) I wanted to try using edge-js because it was already precompiled. I downgraded node to 9.9 (I uninstalled node 10.15.3 and then installed the 9.9.0 msi from the website) because I thought edge-js only supported version 9. Well here I am trying to run edge-js with version 9 and I am still getting an error, although it is a different error.

Here is the code I am trying to run:

var edge = require('edge-js');
var helloWorld = edge.func(function () {/*
async (input) => { 
    return ".NET Welcomes " + input.ToString(); 
}
*/});

helloWorld('JavaScript', function (error, result) {
    if (error) throw error;
    console.log(result);
});
1

There are 1 answers

0
Thrillseeker419 On

I can't believe this worked. It was a syntax error. A problem with the amount of whitespace between the comment and the end of the function. Here is the correct syntax:

var edge = require('edge-js');

var helloWorld = edge.func(function () {
    /*async (input) => { 
        return ".NET Welcomes " + input.ToString(); 
    }*/
});
helloWorld('JavaScript', function (error, result) {
    if (error) throw error;
    console.log(result);
});