Question: babel-cli not working with latest preset


babel-cli not working with latest preset

Answers 2
Added at 2016-12-25 23:12

I've executed the following line, and it compiles fine:

babel src --out-dir lib --presets react,es2015

But when I change es2015 to latest, and run it:

babel src --out-dir lib --presets react,latest

I get the following error:

TypeError: [BABEL] src/MyComponent.js: Invalid options type for /Users/liadrian/Dev/react-reveal-text/node_modules/babel-preset-latest/lib/index.js
    at Logger.error (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/logger.js:39:11)
    at OptionManager.mergeOptions (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:243:16)
    at /usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:349:14
    at /usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:369:24
    at (native)
    at OptionManager.resolvePresets (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:364:20)
    at OptionManager.mergePresets (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:348:10)
    at OptionManager.mergeOptions (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:307:14)
    at OptionManager.init (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/options/option-manager.js:465:10)
    at File.initOptions (/usr/local/lib/node_modules/babel-cli/node_modules/babel-core/lib/transformation/file/index.js:194:75)

I find this to be very strange because I made sure to install the latest preset as is evidenced by the existence of the node_modules/babel-preset-latest/ directory.

And everything works completely fine otherwise. What is it about the latest preset that is causing it to trip? I've tried all of the following presets and they work just fine: es2015, es2016, es2017. It's just the latest preset that is tripping everything up.

Any help on troubleshooting would be greatly appreciated.

EDIT: My package versions

"babel-cli": "^6.18.0",
"babel-core": "^6.21.0",
"babel-preset-latest": "^6.16.0",
"babel-preset-react": "^6.16.0",
Answers to

babel-cli not working with latest preset

nr: #1 dodano: 2016-12-25 23:12

See this tweet by @_jayphelps:

If u experience errors w/ babel like "Invalid options type for" or "Logger.error" or similar, upgrade babel-core!

So try upgrading babel-core and other Babel modules. You can do that with this command:

npm i -D babel-core@latest

i is a shortcut for install, -D adds the package to devDependencies in package.json (it's the same as --save-dev), and @latest installs the latest version available.

nr: #2 dodano: 2016-12-25 23:12

It turns out I was using my globally installed babel-cli instead of using the locally installed one (which was the up-to-date one).

Everything worked smoothly once I ran it like this:

node_modules/babel-cli/bin/babel.js src --out-dir lib --presets react,latest

Thanks to all who helped.

Source Show
◀ Wstecz