Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

babel-node is not recognized as an internal or external command, operable program or batch file

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.

like image 930
Ajay Prajapati Avatar asked Feb 02 '17 11:02

Ajay Prajapati


People also ask

What is Babel CLI npm?

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.

Should I install Babel globally?

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.


3 Answers

you can try install babel's global version

npm install -g babel-cli
like image 179
Esin ÖNER Avatar answered Oct 19 '22 21:10

Esin ÖNER


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

like image 20
Ravin Wijesinghe Avatar answered Oct 19 '22 19:10

Ravin Wijesinghe


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.

like image 15
O.O. Avatar answered Oct 19 '22 21:10

O.O.