When I try to run a JS file by babel command it is showing:
"babel-node is not recognized as an internal or external command, operable program or batch file".
I had created 1.js
file in this written "console.log("hello world")"
;
and tried to run with babel-node command but it is showing the above-mentioned error.
CLI tool. @babel/cli is a tool that allows you to use babel from the terminal. Here's the installation command and a basic usage example: npm install --save-dev @babel/core @babel/cli ./node_modules/.bin/babel src --out-dir lib.
While you can install Babel CLI globally on your machine, it's much better to install it locally project by project. There are two primary reasons for this. Different projects on the same machine can depend on different versions of Babel allowing you to update them individually.
you can try install babel's global version
npm install -g babel-cli
Tried many suggestions and finally, I had to explicitly provide the absolute path to babel-node to get it working in scripts definition section in package.json file.
"start": "nodemon --exec ./node_modules/.bin/babel-node src/index.js"
node - v15.5.1 nodemon - v2.0.7 @babel/node - v7.12.10
Make sure that you have got the babel module so that it can be used.
For example by using npm install babel-cli
to get a node_modules folder.
Then you can find the runnable in node_module/.bin.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With