2016-08-08 40 views
0

Ich aktualisiert auf babel-core 6.13.2 jetzt bekomme ich diesen Fehler.Babel - TypeError: Plugin 1 angegeben in "fremd" wurde erwartet, ein Objekt zurückgeben, wenn aufgerufen, aber zurückgegeben "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) 

Wer hat den Fehler? Vielen Dank.

.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

Was ist Ihr babel Config aussehen? – loganfsmyth

+0

@loganfsmyth meinst du die '.babelrc'? Bitte sehen Sie edit :) – CENT1PEDE

+0

Und was ist in './Server/utils/babelRelayPlugin'? – loganfsmyth

Antwort

0

Ihre Nutzung von fs.access bedeutet, dass Ihre module.exports = Linie nach Babel das Plugin Verarbeitung ausgeführt und abgeschlossen hat bereits laufen. Sie sollten entweder

module.exports = require('babel-relay-plugin')(require(jsonFile).data); 

seit es ist nicht klar, was Sie zu tun versuchen. Ihr aktueller Ansatz, nichts bei einem Fehler zu tun, bedeutet nur, dass es eine Chance gibt, dass Babel läuft, ohne dass das Plugin initialisiert wurde.

Wenn Sie unbedingt brauchen die fs.access zu überprüfen, tun es synchron:

// 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

Keine Änderungen :(Das Problem besteht noch. – CENT1PEDE