Confirm that you have these dependencies at a minimum in your package.json:
"dependencies": {
"@babel/core": "7.13.10",
"@babel/node": "7.13.12",
"@babel/preset-env": "7.13.12",
..
},
"devDependencies": {
"nodemon": "2.0.7",
...
}
Then check what script you are running. If you see the problem when running npm run dev
and you have something like:
"scripts": {
"dev": "nodemon --exec babel-node ./src/server.js",
..
},
Update your scripts to the following (assuming you don't already have a "start"):
"scripts": {
"start": "babel-node ./src/server.js",
"dev": "nodemon --exec npm start",
...
},
Basically, nodeman
is used during dev to hot reload code changes. babel-node
itself runs the server, but the issue being faced occurs when installed package is not detected by nodeman.
Although installing @babel/cli
globally, might appear to resolve the issue, it's not needed (and frowned upon: https://babeljs.io/docs/en/babel-cli)
npm install -g babel-cli
– Misreckon