2016-12-25 5 views
3

で作業していませんバベル-cliを私は次の行を実行してきたが、それがうまくコンパイル最新のプリセット

私は次のエラーを取得する:

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) 

node_modules/babel-preset-latest/ディレクトリの存在が示すように、latestプリセットをインストールするようにしたので、これは非常に奇妙です。

それ以外はすべて正常に動作します。 latestプリセットについて、それが原因でトリップになるのはどうですか?私は以下のプリセットを試してみましたが、うまく動作します:es2015es2016es2017すべてを上げているのは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

@_jayphelpsでthis tweetを参照してください:

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およびその他のバベルのモジュールをアップグレードしてみてください。あなたは、このコマンドを使用していることを行うことができます。

npm i -D [email protected] 

i-Dは、(それが--save-devと同じです)package.jsondevDependenciesにパッケージを追加し、@latestが利用可能な最新バージョンをインストールし、installためのショートカットです。

+0

提案していただきありがとうございます。私はそれをしようとしましたが、同じことが起こっているようです。オリジナルの投稿を特定のバージョン番号で編集しました。 – adrianmc

関連する問題