Instalación de Babel V6.x ES7 Async / Await en Node.js v6.2.0 con Nodemon

El hombre es un dolor de configurar! He seguido las instrucciones de instalación aquí haciendo clic en el cuadro nodemon:

https://babeljs.io/docs/setup/#installation

npm install babel-cli babel-preset-es2015 --save-dev

.babelrc en el directorio raíz:

{
  "presets": ["es2015"],
  "plugins": ["transform-async-to-generator"]
}

package.json (He instalado más cosas de babel como se ve):

...
"devDependencies": {
  "babel-cli": "^6.11.4",
  "babel-core": "^6.13.2",
  "babel-plugin-transform-async-to-generator": "^6.8.0",
  "babel-polyfill": "^6.13.0",
  "babel-preset-es2015": "^6.13.2",
  "babel-preset-node6": "^11.0.0",
  "babel-register": "^6.11.6"
},
"scripts": {
  "startn": "nodemon app.js",
  "babel-node": "babel-node --presets=es2015 --ignore='foo|bar|baz'",
  "babel-dev": "nodemon --exec npm run babel-node -- experiment/socketio/test.js"
},
...

test.js:

(async function () { // <-- error occues here
    const value = await 123;
    console.log(value);
})().then(() => {
    console.log('Done');
});

Ejecuto el comandorun-script babel-dev como se ve a continuación. Error:

karl@karl-ux303ln:~/dev/sketch$ npm run-script babel-dev

> [email protected] babel-dev /home/karl/dev/sketch
> nodemon --exec npm run babel-node -- experiment/socketio/test.js

[nodemon] 1.10.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `npm run babel-node experiment/socketio/test.js`

> [email protected] babel-node /home/karl/dev/sketch
> babel-node --presets=es2015 --ignore='foo|bar|baz' "experiment/socketio/test.js"

/home/karl/dev/sketch/node_modules/babel-core/lib/transformation/file/index.js:591
      throw err;
      ^

SyntaxError: /home/karl/dev/sketch/experiment/socketio/test.js: Unexpected token (1:7)
> 1 | (async function () {
    |        ^
  2 |     const value = await 123;
  3 |     console.log(value);
  4 | })().then(() => {
    at Parser.pp.raise (/home/karl/dev/sketch/node_modules/babylon/lib/parser/location.js:22:13)
    at Parser.pp.unexpected (/home/karl/dev/sketch/node_modules/babylon/lib/parser/util.js:89:8)
    at Parser.pp.expect (/home/karl/dev/sketch/node_modules/babylon/lib/parser/util.js:83:33)
    at Parser.pp.parseParenAndDistinguishExpression (/home/karl/dev/sketch/node_modules/babylon/lib/parser/expression.js:582:12)
    at Parser.pp.parseExprAtom (/home/karl/dev/sketch/node_modules/babylon/lib/parser/expression.js:481:19)
    at Parser.pp.parseExprSubscripts (/home/karl/dev/sketch/node_modules/babylon/lib/parser/expression.js:277:19)
    at Parser.pp.parseMaybeUnary (/home/karl/dev/sketch/node_modules/babylon/lib/parser/expression.js:257:19)
    at Parser.pp.parseExprOps (/home/karl/dev/sketch/node_modules/babylon/lib/parser/expression.js:188:19)
    at Parser.pp.parseMaybeConditional (/home/karl/dev/sketch/node_modules/babylon/lib/parser/expression.js:165:19)
    at Parser.pp.parseMaybeAssign (/home/karl/dev/sketch/node_modules/babylon/lib/parser/expression.js:128:19)

npm ERR! Linux 3.19.0-65-generic
npm ERR! argv "/home/karl/.nvm/versions/node/v6.2.0/bin/node" "/home/karl/.nvm/versions/node/v6.2.0/bin/npm" "run" "babel-node" "experiment/socketio/test.js"
npm ERR! node v6.2.0
npm ERR! npm  v3.8.9
npm ERR! code ELIFECYCLE
npm ERR! [email protected] babel-node: `babel-node --presets=es2015 --ignore='foo|bar|baz' "experiment/socketio/test.js"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] babel-node script 'babel-node --presets=es2015 --ignore='foo|bar|baz' "experiment/socketio/test.js"'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the sketch package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     babel-node --presets=es2015 --ignore='foo|bar|baz' "experiment/socketio/test.js"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs sketch
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls sketch
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/karl/dev/sketch/npm-debug.log
[nodemon] app crashed - waiting for file changes before starting...

También he intentado cambiar al nodo v4.4.7 y actualizar npm a 3.10.6. Sigue siendo el mismo error.

Respuestas a la pregunta(0)

Su respuesta a la pregunta