'Running node app on hosted ubuntu linux results in "unexpected token" when trying to timeout 60_000

I have a node.js app that runs fine on my Mac OS but when trying to run it on a hosted Linux, it says:

/usr/myapp/src/js/main.js:165
        await new Promise(r => setTimeout(r, 60_000))
                                             ^^

SyntaxError: Invalid or unexpected token
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node src/js/main.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-05-03T15_37_28_010Z-debug.log

Any help is welcome. Thanks.



Solution 1:[1]

Was caused by the fact that the version of npm available from apt on Ubuntu (at this time) is too old.

Installing npm doing nvm fixed the issue.

https://linuxize.com/post/how-to-install-node-js-on-ubuntu-20-04/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 D. Joe