Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Babel error: "Couldn't find preset 'latest' relative to directory" when preset was installed globally [duplicate]

I installed Babel globally like this:

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

I know it's not recommended to do it globally, but I prefer this way to keep my directory clean (no node_modules/ and 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 that work?

like image 891
Thomas Avatar asked Dec 06 '16 22:12

Thomas


1 Answers

This already has been mentioned in Babel GitHub Issues: babel-cli and babel-node ignore global presets (installed with npm -g). It seems that there's no way to make it work apart from installing it locally.

like image 80
Michał Perłakowski Avatar answered Oct 20 '22 16:10

Michał Perłakowski