Babel 7 with Node

I am trying to upgrade my Vue.js project that uses Node.js server (with websocket, etc.) from using Babel 6 to Babel 7. I have downloaded the following NPM packages:

- @babel/node
- @babel/preset-env
- @babel/core
- @babel/cli

And here is my current npm script: ./node_modules/.bin/nodemon --exec babel-node server.js --presets @babel/preset-env

Yet. When I run that, I get:

?  ~/vueproj/game git:(feat/items-overhaul) ? ./node_modules/.bin/nodemon --exec babel-node server.js --presets @babel/preset-env
[nodemon] 1.18.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `babel-node server.js --presets @babel/preset-env`
(function (exports, require, module, __filename, __dirname) { export default function _interopRequireDefault(obj) {

SyntaxError: Unexpected token export

I could not find out how to use the CLI as the documentation for that was not good.

You need to install and run @babel/node instead.

npm install --save-dev @babel/node

babel-node runs babel < v7 (calling preset/plugins like babel-preset-env) while @babel/node will call corresponding babel 7 presets/plugins like @babel/preset-env.

and then:

./node_modules/.bin/nodemon --exec ./node_modules/.bin/babel-node server.js

make sure you have a .babelrc which calls babel 7 plugins/presets:

// .babelrc
  "presets": ["@babel/preset-env"]

if you run npx nodemon --help it doesn't mention a --presets option:

  --config file ............ alternate nodemon.json config file to use
  -e, --ext ................ extensions to look for, ie. js,jade,hbs.
  -x, --exec app ........... execute script with "app", ie. -x "python -v".
  -w, --watch path.......... watch directory "path" or files. use once for
                             each directory or file to watch.
  -i, --ignore ............. ignore specific files or directories.
  -V, --verbose ............ show detail on what is causing restarts.
  -- <your args> ........... to tell nodemon stop slurping arguments.