Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: path.replace is not a function

/node_modules/webpack/lib/TemplatedPathPlugin.js:72
        .replace(REGEXP_HASH, withHashLength(getReplacer(data.hash), data.hashWithLength))
         ^

I'm getting this error when running webpack - it seems that path is an object rather than a string, and the replace method is therefore not found. Can anyone shed light on this error? Here's my webpack.config.js:

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

var basePath = 'app';
var outputFile = 'output.js';

var config = {

    entry: basePath + '/index.js',

    output: {
        path: basePath,
        filename: outputFile
    },

    resolve: {
        extensions: ['', '.js']
    },

    module: {
        loaders: [{
            test: /\.js$/,
            exclude: /node_modules/,
            loader: 'babel-loader',
            query: {
                presets: ['es2015']
            }
        }]
    }
};

module.exports = config;
like image 653
babbaggeii Avatar asked Dec 15 '22 03:12

babbaggeii


1 Answers

Check your plugin configuration. Webpack 2 changes the ExtractTextPlugin slightly. It expects all parameters to come wrapped in an object, so your first parameter is now the value of filename on that object rather than a string.

Webpack 1 way: new ExtractTextPlugin('[hash].css', {allChunks: true, disable: false}),

Webpack 2 way: new ExtractTextPlugin({filename: '[hash].css', allChunks: true, disable: false}),

More info in the README

like image 196
Buck Avatar answered Dec 16 '22 17:12

Buck