Babel Error: "Could not find preset" last "relative to directory when preset was set globally

I installed Babel globally as follows:

npm install -g babel-cli npm install -g babel-preset-latest 

I know that this is not recommended globally, but I prefer my directory to be clean (no node_modules / no package.json)

Then I have a mainES6.js file written in ES6 that I want in ES5, so I do this:

 babel mainES6.js -o mainES5.js --presets latest 

And I get this message: Error: Couldn't find preset "latest" relative to directory "/path/to/my/file/"

How to make this work?

+7
javascript npm babeljs
source share
1 answer

This has already been mentioned in Babel GitHub: babel-cli and babel-node ignore global presets (installed with npm -g) . There seems to be no way to make it work separately from its local local use.

+4
source share

All Articles