2016-06-30 10 views
0

Ich war erfolgreich beim Einrichten der Reaktion Entwicklung eingerichtet. Aber das Ausführen von npm Start gibt folgenden Fehler.TypeError: Objekt # hat keine Methode 'forEach' bei der neuen LoadersList beim Einrichten des Reaktionsprojekts

Ich kann nicht herausfinden, woher dieser Fehler generiert wird. Bitte helfen!

TypeError: Object #<Object> has no method 'forEach' at new LoadersList 
    (C:\Users\User\AppData\Roaming\npm\node_modules\webpack\node_modules\webpack- 
    core\lib\LoadersList.js:7:12) at new NormalModuleFactory (C:\Users 
    \User\AppData\Roaming\npm\node_modules\webpack 
    \lib\NormalModuleFactory.js:16:17) at Compiler.createNormalModuleFactory 
    (C:\Users\User\AppData\Roaming\npm\node_modules\webpack  
    \lib\Compiler.js:369:28) at Compiler.newCompilationParams (C:\Users  
    \User\AppData\Roaming\npm\node_modules\webpack\lib\Compiler.js:382:29) at 
    Compiler.compile (C:\Users\User\AppData\Roaming\npm\node_modules\webpack 
    \lib\Compiler.js:389:20) at Watching.<anonymous> (C:\Users\User\AppData 
    \Roaming\npm\node_modules\webpack\lib\Compiler.js:46:17) at Compiler.next 
    (C:\Users\User\AppData\Roaming\npm\node_modules\webpack\node_modules\tapable 
    \lib\Tapable.js:67:11) at Compiler.invalidAsyncPlugin (C:\Users\User\AppData 
    \Roaming\npm\node_modules\webpack-dev-server\node_modules\webpack- 
    dev-middleware\middleware.js:80:3) at Compiler.applyPluginsAsync (C:\Users 
    \User\AppData\Roaming\npm\node_modules\webpack\node_modules\tapable 
    \lib\Tapable.js:71:13) at Watching._go (C:\Users\User\AppData\Roaming 
    \npm\node_modules\webpack\lib\Compiler.js:44:16) 

Bitte vorschlagen. Vielen Dank!

Antwort

0
Object #<Object> has no method 'forEach' 

    forEach will work for Array, means looping the array, 
but in your case your calling the method `forEach` in Object. 

Richtig:

[].forEach. 

, was Sie tun, ist:

{}.forEach 
+0

Hallo, eigentlich haben begann ich einen Code zu schreiben. Dies scheint automatisch generiert zu werden, also bin ich ratlos, wo es verwendet werden könnte. –

+0

irgendwelche Vorschläge, wo die Ursache sein könnte? –

0

, wenn jemand das gleiche Problem gegenübersteht, ist der Grund, weil die Lader in webpack.config.js a war Objekt anstelle von Array von Objektwerten.

dh. Alle Lader müssen in einem Array verpackt sein. als Array von Objekten.

module:{ loaders:**[** { test:/\.jsx?$/, exclude:/node_modules/, loader:'babel', query:{ presets:['react','es2015'] } } **]** }