I am trying to run my project with node server.js and i am getting following error.
/Library/WebServer/Documents/PROJECT/node_modules/express-validator/lib/express_validator.js:75
chain[name] = (...options) => {
^^^
SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/Library/WebServer/Documents/PROJECT/node_modules/express-validator/index.js:1:80)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
I am using Express.js framework. It was working fine last time when i worked on it.
After searching a lot i finally found that for one of my project which was build with nodejs older version i was using node@4.4.7
and after changing node version on my local machine with following:
nvm ls // to check out what versions of Node.js are installed on your machine
-> v4.4.7
v8.9.1
system
default -> 4.4.7 (-> v4.4.7)
To switch Node.js from node@4.4.7
to node@8.9.1
i have used following command:
nvm use v8.9.1
To verify i check again with nvm ls
and now it shows.
v4.4.7
-> v8.9.1
system
default -> 4.4.7 (-> v4.4.7)