2017-03-23 15 views
7

मैं नोड के लिए नया हूँ और है कि किसी ऐप बनाया कुछ async उस में/इंतजार वाक्य रचना इसलिए की तरह:हेरोोकू पर सक्षम ES2017 सुविधाओं के साथ Node.js ऐप कैसे चलाएं?

const express = require('express'); 
const app = express(); 

const someLibrary = require('someLibrary'); 

function asyncWrap(fn) { 
    return (req, res, next) => { 
    fn(req, res, next).catch(next); 
    }; 
}; 

app.post('/getBlock', asyncWrap(async (req,res,next) => { 
    let block = await someLibrary.getBlock(req.body.id); 
    [some more code] 
})); 

app.listen(process.env.PORT || 8000); 

यह मेरी मशीन पर ठीक काम करता है लेकिन जब मैं Heroku को तैनात रहा क्योंकि वाक्य रचना में त्रुटि मिली समर्थित नहीं है:

2017-03-23T10:11:13.953797+00:00 app[web.1]: app.post('/getBlock', asyncWrap(async (req,res,next) => { 
2017-03-23T10:11:13.953799+00:00 app[web.1]: SyntaxError: Unexpected token (

हेरोकू इस वाक्यविन्यास का समर्थन करने का सबसे आसान तरीका क्या है?

+0

'async/await' ES2017 का हिस्सा है, ES7 नहीं। –

उत्तर

2

निर्दिष्ट करने के लिए चाहता हूँ यहाँ

https://devcenter.heroku.com/articles/getting-started-with-nodejs#declare-app-dependencies

प्रलेखन यह आपके package.json फ़ाइल जो इंजन (रों) एसी होना चाहिए में घोषित किया जाना चाहिए स्वीकार्य:

{ 
    "name": "node-js-getting-started", 
    "version": "0.2.5", 
    ... 
    "engines": { 
    "node": "5.9.1" 
    }, 
    "dependencies": { 
    "ejs": "2.4.1", 
    "express": "4.13.3" 
    }, 
    ... 
} 
संबंधित मुद्दे