I want to transpile several js files that are in ES6 to be compatible with chrome, but it seems the docs in http://babeljs.io/docs/usage/cli/ are not accurate.
After doing the first few steps I type in the console: babel
and get:
You have mistakenly installed the
babel
package, which is a no-op in Babel 6. Babel's CLI commands have been moved from thebabel
package to thebabel-cli
package.npm uninstall babel npm install --save-dev babel-cli
See http://babeljs.io/docs/usage/cli/ for setup instructions.
And even if I run those two commands it mention, I still get the same error.
So my question is how are you supposed to transpile files with Babel and CLI?
A bit old question, but in case someone ended here through Google like me:
I had the same problem, just ran
npm install --save-dev babel-cli
in a new and completely empty directory in order to test something and could not transpile when calling babel through npx with the same error. I didn't have Babel installed globally, but after a while I noticed npm didn't create the package.json file. So I deleted everything, created empty package.json with just
{
}
installed babel-cli again (npm now added dev dependency to the json file) and now it works fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.