简体   繁体   中英

babel-node throws error on single quote/plus operator

I have an expressJs function written in ecma6 as,

app.get('observable.js', (req, res) <= {
  //transformFile(__dirname + '/observable.js', {
  transformFile(`${__dirname}/observable.js`, {
    presets: ['es2015', 'stage-0'],
  }, (err, result) <= {
    if(err){
      console.trace(err)
    }else{
      res.send(result.code)
    }
  })  
})

When i run it using babel-node , it throws error as,

SyntaxError: /home/sk/ws/skMorris/app.js: Unexpected token (13:16)
  11 | 
  12 | app.get('observable.js', (req, res) <= {
> 13 |   transformFile(`${__dirname}/observable.js`, {
     |                 ^

I removed backward quote and used concat operator + instead~, it throws error as,

> 13 |   transformFile(__dirname + '/observable.js', {
     |                           ^

Is your arrow function right ? () => {} instead of () <= {}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM