Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Babel installation - src doesnt exist

quick question. Found similar cases but they dont worked for me.

Following this guide https://babeljs.io/docs/setup/#installation I´m trying to install Babel Cli.

but running babel from a command in package.json configured like

"scripts": {
    "build": "babel src -d lib"
},

throwing an error

> babel src -d lib

src doesn't exist
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `babel src -d lib`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely 
additional logging output above.

npm ERR! A complete log of this run can be found in:

when running the command npm run build

I´ve already installed babel-preset-env and configured a .babelrc

npm version 6.1.0

Do you know where src doesn't exist comes from ? Thanks!

like image 886
mxkraus Avatar asked May 31 '18 19:05

mxkraus


People also ask

How do I know if Babel is installed?

You can also check the version of babel-cli by finding the babel-cli folder in node_modules and looking at the version property of the package. json that is at the base of that folder. If babel-cli was installed globally via -g flag of npm install , you could check the version by executing command babel --version .

How do you add Babel in HTML?

You just need to load the “babel-standalone” in your script as highlighted below and write the script you want to transpile, in script tag with type “text/babel” or “text/jsx”. Babel will automatically compile and execute the script. Let us create an example html file with ES6 to see how it works.


1 Answers

src is the folder that contains the files you want to transform. Either create it and move your files there or update the command to use the folder that contains your files.

More info: https://babeljs.io/docs/usage/cli/#compile-directories

like image 181
Felix Kling Avatar answered Oct 18 '22 19:10

Felix Kling