Search code examples
javascriptnode.jsnode-modulesnodemon

nodemon show error for es16


I have Ubuntu 16.10 and node.js 7

nodejs -v
v7.6.0

I have installed sudo npm install supervisor -g for auto-reload node.js. But if I write for example arrow function then I see error:

user@user-pc:~/dev/a$ nodemon  app.js
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `node app.js`
/home/user/dev/a/app.js:11
app.get('/rtc', (req, res)=>{
                          ^^
SyntaxError: Unexpected token =>
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3
[nodemon] app crashed - waiting for file changes before starting...

If i run my app simple nodejs app.js then all is finely.


Solution

  • It seems, that nodejs is using ES6/E2015 and nodemon not. Combining the hint from the babel-installation I propose a nodemon --exec nodejs for a trial...