Ich lerne ReactJS. Die Installation wurde durchgeführt, aber wenn ich diesen npm-Befehl ausführe, erhalte ich den folgenden Fehler.npm Lauf Fehler Reaktion js
[email protected]:/var/www/reactjsbasics$ npm run build
> [email protected] build /var/www/reactjsbasics
> webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --watch
/var/www/reactjsbasics/node_modules/webpack/bin/convert-argv.js:487
throw new Error("'output.filename' is required, either in config file or as --output-filename");
^
Error: 'output.filename' is required, either in config file or as --output-filename
at processOptions (/var/www/reactjsbasics/node_modules/webpack/bin/convert-argv.js:487:11)
at processConfiguredOptions (/var/www/reactjsbasics/node_modules/webpack/bin/convert-argv.js:136:4)
at module.exports (/var/www/reactjsbasics/node_modules/webpack/bin/convert-argv.js:112:10)
at Object.<anonymous> (/var/www/reactjsbasics/node_modules/webpack/bin/webpack.js:155:40)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --watch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
┌────────────────────────────────────────── ────────── │ npm Update-Prüfung fehlgeschlagen │ │ Versuchen Sie, mit sudo zu laufen oder Zugriff │ │ zum lokalen Update-Config-Store über │ │ sudo chown -R $ USER: $ (id -gn $ USER) /home/me/.config │ └─────────────────────────────────────────────────────────────────────────────────────────────── ───────────────────
npm ERR! A complete log of this run can be found in:
npm ERR! /home/me/.npm/_logs/2017-07-18T06_15_33_602Z-debug.log
webpack.config.js
var webpack=require("webpack");
var path=require("path");
var DIST_DIR = path.resolve(__dirname,"dist");
var SRC_DIR = path.resolve(__dirname,"src");
var config={
entry:SRC_DIR + "/app/index.js",
output:{
path:DIST_DIR+"/app",
filename:"bundle.js",
publicPath:"/app/"
},
module:{
loaders:[
{
test:"/\.js?/",
include:SRC_DIR,
loader:"babel-loader",
query:{
presets:["react","es2015","stage-2"]
}
}
]
}
};
package.json
"scripts": {
"start":"npm run build",
"build":"webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --watch",
"build:prod":"webpack -p && cp src/index.html dist/index.html"
},
Modul zu exportieren && verschiedene module.exports? – hir
@hir Was meinst du? 'config.module'? Ich meine, Sie müssen das gesamte 'config' Objekt aus der' webpack.config.js' Datei exportieren. –