2016-12-25 3 views
3

я выполнил следующую строку, и она отлично компилируется:столпотворение-кли не работает с последней заданной

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

Но когда я изменяю es2015 к latest, и запустить его:

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

я получаю следующее сообщение об ошибке:

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 Array.map (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) 

Я считаю это очень странным, потому что я обязательно установил пресет latest, о чем свидетельствует существование каталога node_modules/babel-preset-latest/.

И все работает совершенно нормально. Что это за предустановка latest, вызывающая его? Я пробовал все следующие пресеты, и они отлично работают: es2015, es2016, es2017. Это всего лишь предустановка latest, которая отключает все.

Любая помощь по поиску и устранению неисправностей будет принята с благодарностью.

EDIT: Мой пакет версии

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

ответ

2

Получается, что я использовал мой глобально установленный babel-cli вместо того, чтобы использовать локально установленный (который был последним).

Все работало гладко, как только я побежал так:

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

Спасибо всем, кто помог.

2

См this tweet по @_jayphelps:

If u experience errors w/ babel like "Invalid options type for" or "Logger.error" or similar, upgrade babel-core! https://github.com/babel/babel/pull/3635

Так попробуйте обновить babel-core и другие модули Babel. Вы можете сделать это с помощью этой команды:

npm i -D [email protected] 

i ярлык для install, -D добавляет пакет devDependencies в package.json (это то же самое, как --save-dev) и @latest устанавливает самую последнюю доступную версию.

+0

Спасибо за предложение. Я пытался это сделать, но похоже, что это происходит. Я редактировал свое оригинальное сообщение с конкретными номерами версий. – adrianmc