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!
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 .
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.
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
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