2016-03-21 10 views
-2

Im neu zu NodeJS und webpack definiert,webpack Config-Hilfe wird __dirname nicht

im folgenden ein Tutorial über webpack und wann haben webpack.config.js zu erstellen und auszuführen webpack -c webpack.config.js es Rückkehr:

webpack -c webpack.config.js 

/home/arma/bin/nodejs/webpack.config.js:15 
     root: path.join(__dirname, './src'), 
         ^
ReferenceError: __diranme is not defined 
    at Object.<anonymous> (/home/arma/bin/nodejs/webpack.config.js:15:25) 
    at Module._compile (module.js:456:26) 
    at Object.Module._extensions..js (module.js:474:10) 
    at Module.load (module.js:356:32) 
    at Function.Module._load (module.js:312:12) 
    at Module.require (module.js:364:17) 
    at require (module.js:380:17) 
    at module.exports (/usr/lib/node_modules/webpack/bin/convert-argv.js:80:13) 
    at Object.<anonymous> (/usr/lib/node_modules/webpack/bin/webpack.js:39:40) 
    at Module._compile (module.js:456:26) 

Mein webpack.config.js:

var path = require('path'); 

module.exports = { 
    context: __dirname, 
    entry: [ 
     './src/index.js', 
    ], 
    output: { 
     path: path.join(__dirname, 'build'), 
     filename: 'output.js', 
     publicPath: 'assets', 
    }, 
    resolve: { 
     extensions: ['','.js'], 
     root: path.join(__diranme, './src'), 
    } 
}; 

Mein System Fedora 23:

Linux x-wing 4.4.5-300.fc23.x86_64 #1 SMP Thu Mar 10 17:54:44 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux 

NodeJS Version:

v0.10.42 

Dank für Ihre Hilfe: D

Antwort

2

Umbenennen __dirname. Sie haben einen Tippfehler im Abschnitt "Auflösen". Auch in deinem Posttitel :-)

+0

was für ein Idiot bin ich! Vielen Dank :) aber jetzt habe ich Fehler in Multi-Haupt Modul nicht gefunden: Fehler: Kann nicht 'Datei' oder 'Verzeichnis' ./src/index.js in __dirname @ multi Haupt – starbuck

+1

Bitte kennzeichnen Tippfehler Fragen aus -Thema. –

+0

Was ist der bessere Weg, um Fragen als nicht-thematisch zu markieren? –