tjanczuk / edge

Run .NET and Node.js code in-process on Windows, MacOS, and Linux
http://tjanczuk.github.io/edge
Other
5.42k stars 640 forks source link

Inner Exception SyntaxError: Unexpected token ... #704

Closed Hate9 closed 3 days ago

Hate9 commented 4 years ago

I'm running the demo ws script from the readme page:

    public static async void Start()
    {
        var createWebSocketServer = Edge.Func(@"
        var WebSocketServer = require('ws').Server;

        return function (port, cb) {
            var wss = new WebSocketServer({ port: port });
            wss.on('connection', function (ws) {
                ws.on('message', function (message) {
                    ws.send(message.toUpperCase());
                });
                ws.send('Hello!');
            });
            cb();
        };
    ");

        await createWebSocketServer(8080);
    }

    Task.Run(Start);
    new ManualResetEvent(false).WaitOne();

But I'm getting an error:

    Exception: D:\Documents\Visual Studio 
    Projects\DiscordConsoleClient\bin\Debug\node_modules\ws\lib\websocket.js:348
          ...options
          ^^^

    SyntaxError: Unexpected token ...
        at createScript (vm.js:74:10)
        at Object.runInThisContext (vm.js:116:10)
        at Module._compile (module.js:533:28)
        at Object.Module._extensions..js (module.js:580:10)
        at Module.load (module.js:503:32)
        at tryModuleLoad (module.js:466:12)
        at Function.Module._load (module.js:458:3)
        at Module.require (module.js:513:17)
        at require (internal/module.js:11:18)
        at Object.<anonymous> (D:\Documents\Visual Studio 
    Projects\DiscordConsoleClient\bin\Debug\node_modules\ws\index.js:3:19)

Any idea what's wrong?

hbdbim commented 2 years ago

Same here

tarekahf commented 2 years ago

I have the same problem. Any update on this issue?

tarekahf commented 2 years ago

I also reported the problem here:

https://stackoverflow.com/q/71807544/4180447

tarekahf commented 2 years ago

I confirmed if I use newman version 4.6.1 the problem will be resolved. Also, I think if I use Babel to transpile all the newman code in the node_modules folder, then it will work, but how to do that?

If I managed to transpile all code under node_modules and the output is node_modules_dist then how it will be picked up with the node API const newman=require("newman")?

agracio commented 3 days ago

This repo is no longer supported, there are no issues with demo in new repo https://github.com/agracio/edge-js.