据说node7.0已经支持async/await,那么下面的代码为什么运行不了?
var sleep=function(time){ return new Promise(function(resolve,reject){ setTimeout(function(){ resolve('ok'); },time); }); }; async function start(){ let result =await sleep(3000); console.log(result); } start();
三叔2016-11-01 11:00:33
node --harmony myapp.js
https://nodejs.org/en/docs/es6/
All ECMAScript 2015 (ES6) features are split into three groups for shipping, staged, and in progress features: All shipping features, which V8 considers stable, are turned on by default on Node.js and do NOT require any kind of runtime flag. Staged features, which are almost-completed features that are not considered stable by the V8 team, require a runtime flag: --harmony. In progress features can be activated individually by their respective harmony flag, although this is highly discouraged unless for testing purposes. Note: these flags are exposed by V8 and will potentially change without any deprecation notice.