0

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? Commented Dec 16, 2015 at 22:58
  • I know the node version. I dont know how to check javascript/ES version and how to change it to ES6 Commented Dec 16, 2015 at 23:04
  • /usr/bin/canvasDataCli sampleConfig Commented Dec 16, 2015 at 23:16

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.