Webpack运行,Elixir抛出错误 - undefined不是一个函数

时间:2016-11-17 22:32:51

标签: laravel-5 webpack laravel-elixir

我把头发拉了几个小时后,终于让webpack在现有的项目上运行,我正试图移植到Laravel。

当我运行webpack时,它现在编译......

...但是当我在执行Elixir的root中运行gulp时,我收到此错误消息:

  

node_modules / webpack / lib / NullFactory.js:9 undefined不是函数

enter image description here

我的webpack.config.js看起来像这样:

var path = require('path');
var webpack = require('webpack');
var debug = process.env.NODE_ENV !== "production";

module.exports = {
  devtool: 'source-map',
  entry: debug ? [
    'webpack-hot-middleware/client',
    './resources/assets/js/client/index'
  ] : [
    './resources/assets/js/client/index'
  ],
  output: {
    path: path.join(__dirname, 'public/js'),
    filename: 'bundle.js',
    publicPath: '/static/'
  },
  plugins: debug ? [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin()
    ] : [
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.OccurenceOrderPlugin(),
    new webpack.DefinePlugin({
      'process.env': {
        'NODE_ENV': "'production'"
      }
    }),
    new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false,warnings: false })
  ],
  resolve: {
    root: [
      path.resolve('./resources/assets/js/client')
    ],
    alias: {

    },
  },
  module: {
    loaders: [
    // js
    {
      test: /\.js$/,
      loaders: ['babel'],
      include: path.join(__dirname, 'resources/assets/js/client')
    },
    // CSS
    { 
      test: /\.styl$/,
      include: path.join(__dirname, 'resources/assets/js/client'),
      loader: 'style-loader!css-loader!stylus-loader'
    },
    {
      test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192'
    },
    {
      test: /\.json?$/,
      loader: 'json'
    },
    { test: /\.html$/, loader: "html" }
     /* {
        test: /\.jsx?$/,
        loader: 'babel',
        exclude: /node_modules/,
        query: {
          cacheDirectory: true,
          presets: ['react', 'es2015']
        }
      }*/
    ]
  }
};

1 个答案:

答案 0 :(得分:0)

好的,我有非常过时的Node版本...升级修复它。