Issue:
Unable to use Babel Transpiler with Nodemon
Details:
In package.json I have:
"scripts": {
"start": "nodemon --exec babel-node --presets=es2015 -- src/app.js"
},
"dependencies": {
"nodemon": "^1.18.4"
},
"devDependencies": {
"@babel/cli": "^7.1.2",
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0"
}
When I run npm start
My understanding is that nodemon should kick on save and run the babel transpiler; however, I get the following in the terminal.
Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of @babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel.
I thought this was caused by the babel-cli
dependency of 6.26 but when I remove that it squawks:
[nodemon] failed to start process, "babel-node" exec not found
Searching through the good ol' google machine I see some other people with more complicated setups and their solutions seem to fly over the top of my head.
Recreation Steps:
Run
npm init -y
&npm i nodemon
Follow instructions here: https://babeljs.io/setup#installation (nodemon) selected
Run
npm install @babel/core --save-dev
as I was warned that the core was not installed.Run
npm start