简体   繁体   中英

Webpack: You may need an appropriate loader to handle this file type

I have a little nodejs project with webpack. Iam relatively new to webpack so i think thats the problem.

If i install log4js, winston or other logger libraries and run the application i am getting

WARNING in ./~/log4js/lib/log4js.js
Critical dependencies:
388:21-38 the request of a dependency is an expression
 @ ./~/log4js/lib/log4js.js 388:21-38

WARNING in ./~/log4js/lib/appenders/logstashUDP.js.orig
Module parse failed: /Users/me/Development/jstemplate/node_modules/log4js/lib/appenders/logstashUDP.js.orig Line 31: Unexpected token <<
You may need an appropriate loader to handle this file type.
| 
|     var logObject = {
| <<<<<<< HEAD
|       '@timestamp': (new Date(loggingEvent.startTime)).toISOString(),
|       type: type,
 @ ./~/log4js/lib/appenders ^\.\/.*$

here is my webpack config

var webpack = require('webpack');
var path = require('path');

var APP_DIR = path.join(__dirname, '..', 'src');

var devFlagPlugin = new webpack.DefinePlugin({  
  __DEV__: JSON.stringify(JSON.parse(process.env.DEBUG || 'false'))
});

module.exports = {
  debug: true,
  devtool: 'eval',
  entry: ['webpack-hot-middleware/client', './src/index.tsx'],
  module: {
    preLoaders: [{
      test: /\.tsx?$/,
      loader: 'tslint',
      include: APP_DIR
    }],
    loaders: [{
        test: /\.tsx?$/,
        loaders: ['babel', 'ts'],
        include: APP_DIR
    }]
  },
  output: {
    filename: 'app.js',
    path: path.join(__dirname, '..', 'build'),
    publicPath: '/static/'
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoErrorsPlugin(),
    devFlagPlugin
  ],
  resolve: {
    root: [path.resolve('../src')],
    extensions: ['', '.jsx', '.js', '.tsx', '.ts', '.json']
  },
  resolveLoader: {
    root: '../node_modules'
  },
  node: {
    fs: "empty"
  }
};

Open this file. It is corrupted.

    var logObject = {
<<<<<<< HEAD
      '@timestamp': (new Date(loggingEvent.startTime)).toISOString(),
      type: type,
      message: logMessage,
      fields: fields,
      category: loggingEvent.logger.category
=======
      "@version" : "1",
      "@timestamp" : (new Date(loggingEvent.startTime)).toISOString(),
      "type" : config.logType ? config.logType : config.category,
      "message" : layout(loggingEvent),
      "fields" : _.extend(config.fields,
                    loggingEvent.data.length > 1 ? loggingEvent.data[1] : {},
                    {'level':loggingEvent.level.levelStr})
>>>>>>> jumpgh-master
    };

Looks like merge conflict. Looks like problem with this module, not with webpack.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM