edge icon indicating copy to clipboard operation
edge copied to clipboard

Inner Exception SyntaxError: Unexpected token ...

Open Hate9 opened this issue 4 years ago • 4 comments

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?

Hate9 avatar May 11 '20 21:05 Hate9

Same here

hbdbim avatar Jan 07 '22 17:01 hbdbim

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

tarekahf avatar Apr 09 '22 10:04 tarekahf

I also reported the problem here:

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

tarekahf avatar Apr 09 '22 12:04 tarekahf

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")?

tarekahf avatar Apr 17 '22 07:04 tarekahf