0
votes

FYI:I have never worked on NodeJS before I have a small nodejs(5.2) scriptlet and while trying to run it I get this error. It looks like it is because an older javascript runtime/interpreter is being used as it is not picking up the three dot notation. How do I check the version of ES/Javascript and install and switch to ES6 on my system (Fedora 23).

/usr/lib/node_modules/canvas-data-cli/lib/logger.js:17 logIt(level, ...args) { ^^^

SyntaxError: Unexpected token ... at exports.runInThisContext (vm.js:54:16) at Module._compile (module.js:375:25) at Object.Module._extensions..js (module.js:406:10) at Module.load (module.js:345:32) at Function.Module._load (module.js:302:12) at Module.require (module.js:355:17) at require (internal/module.js:13:17) at Object. (/usr/lib/node_modules/canvas-data-cli/lib/cli.js:4:14) at Module._compile (module.js:399:26) at Object.Module._extensions..js (module.js:406:10)

3
How do you invoke the scriptlet? - davejagoda
I know the node version. I dont know how to check javascript/ES version and how to change it to ES6 - Fahad Bukhari
/usr/bin/canvasDataCli sampleConfig - Fahad Bukhari

3 Answers

3
votes

To check node version:

node -v

I suggest you use nvm to manage node versions.

From its github readme page:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash
nvm install 5.2
nvm use 5.2

And then you can just use node as normal, it will be 5.2.

1
votes

Node 5 does not support rest operators yet, without a specific runtime flag.

You can check support tables for your version at: https://kangax.github.io/compat-table/es6/#test-rest_parameters_basic_functionality

0
votes

If you don't want to worry about knowing which versions of node support native ES6 capabilities look into using Babel to transpile your code. You can take advantage of ES7 features as well.