Question

Why is the Javascript not not starting?

I am running an UBUNTU 14 , trying to start a Javascript not for my game webapp but it returns This error:

:/var/www/html/bot# pm2 start site.js /usr/lib/node_modules/pm2/bin/pm2:940 .action(() => { ^ SyntaxError: Unexpected token ) at exports.runInThisContext (vm.js:73:16) at Module._compile (module.js:443:25) at Object.Module._extensions…js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.Module.runMain (module.js:501:10) at startup (node.js:129:16) at node.js:814:3

Subscribe
Share

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

That looks like the type of problem that comes up when your program is expecting a newer version of node or the javascript language than what your project is currently using.

The action(() => { syntax is an arrow function, a newer syntax to javascript introduced in ECMAScript 6/2015 spec. It has been supported in Node.js since version 6+

Potential Solution 1: See if you have an old version of node. Run node -v in the command line, confirm that you have a version greater than 6, if you have an old version follow these instructions to install nvm so you can just run a newer version of node for this bot project.

Potential Solution 2: Make sure there is a file here: /var/www/html/bot/.babelrc that contains:

{
"presets": [ "es2015" ]
}

You can check for the file by running ls -a and looking for it.

Thanks a lot… worked now. used solution 1