2016-08-08 1 views
0

babel-core 6.13.2にアップグレードしました。Babel - TypeError: "foreign"で指定されたプラグイン1は、呼び出されたときにオブジェクトを返すと予想されましたが、 "boolean"を返しました

/var/www/html/kalahi-rf/node_modules/babel-core/lib/transformation/file/options/option-manager.js:120 
    throw new TypeError(messages.get("pluginNotObject", loc, i, typeof obj === "undefined" ? "undefined" : (0, _typeof3.default)(obj)) + loc + i); 
^

TypeError: Plugin 1 specified in "foreign" was expected to return an object when invoked but returned "boolean"foreign1 

at Function.memoisePluginContainer (/var/www/html/kalahi-rf/node_modules/babel-core/lib/transformation/file/options/option-manager.js:120:13) 

at Function.normalisePlugin (/var/www/html/kalahi-rf/node_modules/babel-core/lib/transformation/file/options/option-manager.js:141:32) 
at /var/www/html/kalahi-rf/node_modules/babel-core/lib/transformation/file/options/option-manager.js:181:30 
at Array.map (native) 
at Function.normalisePlugins (/var/www/html/kalahi-rf/node_modules/babel-core/lib/transformation/file/options/option-manager.js:153:20) 
at OptionManager.mergeOptions (/var/www/html/kalahi-rf/node_modules/babel-core/lib/transformation/file/options/option-manager.js:245:36) 
at /var/www/html/kalahi-rf/node_modules/babel-core/lib/transformation/file/options/option-manager.js:254:17 
at /var/www/html/kalahi-rf/node_modules/babel-core/lib/transformation/file/options/option-manager.js:342:20 
at Array.map (native) 
at OptionManager.resolvePresets (/var/www/html/kalahi-rf/node_modules/babel-core/lib/transformation/file/options/option-manager.js:305:20) 
at OptionManager.mergeOptions (/var/www/html/kalahi-rf/node_modules/babel-core/lib/transformation/file/options/option-manager.js:253:29) 
at OptionManager.init (/var/www/html/kalahi-rf/node_modules/babel-core/lib/transformation/file/options/option-manager.js:383:12) 
at compile (/var/www/html/kalahi-rf/node_modules/babel-register/lib/node.js:103:45) 
at loader (/var/www/html/kalahi-rf/node_modules/babel-register/lib/node.js:148:14) 
at Object.require.extensions.(anonymous function) [as .js] (/var/www/html/kalahi-rf/node_modules/babel-register/lib/node.js:158:7) 
at Module.load (module.js:458:32) 

誰でもエラーが発生しますか?ありがとう。

.babelrc

{ 
    "plugins": ["./server/utils/babelRelayPlugin"], 
    "presets": ["react", "es2015", "stage-0"], 
    "env": { 
    "development": { 
     "plugins": [ 
     ["react-transform", { 
      "transforms": [{ 
      "transform": "react-transform-hmr", 
      "imports": ["react"], 
      "locals": ["module"] 
      }, { 
      "transform": "react-transform-catch-errors", 
      "imports": ["react", "redbox-react"] 
      }] 
     }] 
     ] 
    } 
    } 
} 

babelRelayPlugin

/* eslint-disable no-var, func-names, prefer-arrow-callback, global-require */ 
var fs = require('fs'); 
var path = require('path'); 
var jsonFile = path.join(__dirname, '../data/schema.json'); 

// Read the schema.json file only if it exists, this fixed 
// the problem of using babelRelayPlugin, defined in .babelrc, 
// and running npm run update when the file doesn't exist 
fs.access(jsonFile, fs.F_OK, function (err) { 
    if (!err) module.exports = require('babel-relay-plugin')(require(jsonFile).data); 
}); 
+0

を何あなたのバベルの設定は次のようになり? – loganfsmyth

+0

@loganfsmythあなたは '.babelrc'を意味しますか? edit: – CENT1PEDE

+0

そして '。/ server/utils/babelRelayPlugin'には何が入っていますか? – loganfsmyth

答えて

0

fs.accessのご利用状況はバベルがすでに実行して、プラグインの処理を完了した後にmodule.exports =行がを実行できることを意味します。あなたがしようとしていることが明確でないため、

のいずれかにする必要があります。エラーで何もしない現在の方法は、プラグインが初期化されていない状態でBabelが実行される可能性があることを意味します。

あなたは絶対にfs.accessチェックが必要な場合は、同期的にそれを行う:

// Read the schema.json file only if it exists, this fixed 
// the problem of using babelRelayPlugin, defined in .babelrc, 
// and running npm run update when the file doesn't exist 
try { 
    fs.accessSync(jsonFile, fs.F_OK); 

    module.exports = require('babel-relay-plugin')(require(jsonFile).data); 
} catch(e) {} 
+0

変更なし:(まだ問題はあります。 – CENT1PEDE

関連する問題