Node.js SyntaxError:意外标记。。。在node_modules/express validator/lib/express_validator.js:75中
我正在尝试使用node server.js运行我的项目,我遇到以下错误Node.js SyntaxError:意外标记。。。在node_modules/express validator/lib/express_validator.js:75中,node.js,express,express-validator,Node.js,Express,Express Validator,我正在尝试使用node server.js运行我的项目,我遇到以下错误 /Library/WebServer/Documents/PROJECT/node_modules/express-validator/lib/express_validator.js:75 chain[name] = (...options) => { ^^^ SyntaxError: Unexpected token ... at export
/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)
/Library/WebServer/Documents/PROJECT/node\u modules/express validator/lib/express\u validator.js:75
链[名称]=(…选项)=>{
^^^
SyntaxError:意外标记。。。
在exports.runInThisContext(vm.js:53:16)
在模块处编译(Module.js:373:25)
在Object.Module.\u extensions..js(Module.js:416:10)
在Module.load(Module.js:343:32)
在Function.Module.\u加载(Module.js:300:12)
at Module.require(Module.js:353:17)
根据需要(内部/module.js:12:17)
在对象上。(/Library/WebServer/Documents/PROJECT/node\u modules/express validator/index.js:1:80)
在模块处编译(Module.js:409:26)
在Object.Module.\u extensions..js(Module.js:416:10)
我使用的是Express.js框架。上次我使用它时,它工作得很好。在搜索了很多之后,我终于发现我的一个项目使用的是nodejs旧版本node@4.4.7在本地计算机上更改节点版本后,请执行以下操作:
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)
从node@4.4.7
至node@8.9.1
我使用了以下命令:
nvm use v8.9.1
为了验证,我再次用nvm ls
检查,现在它显示出来了
v4.4.7
-> v8.9.1
system
default -> 4.4.7 (-> v4.4.7)
是,ES6中可用的扩展运算符将从版本8及以上的节点8中可用。错误--。