npm run error реагирует на js

Я учу ReactJS. Установка была завершена, но когда я запускаю эту команду npm, я получаю следующую ошибку.

     me@R-SOFT-85:/var/www/reactjsbasics$ npm run build
         > reactjsbasics@1.0.0 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! reactjsbasics@1.0.0 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 reactjsbasics@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

┌───────────────────────────────────────────────── ─────────┐ check Проверка обновления npm не удалась │ │ Попробуйте запустить с sudo или получить доступ │ │ к локальному хранилищу настроек обновлений через │ │ 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"
    },

1 ответ

Решение

Похоже, вы забыли экспортировать свой конфиг

// webpack.config.js

var config = {
 ...

}; 

// you need to export config object
module.exports = config
Другие вопросы по тегам