webpack 生成source-map时报错

ssss
  • 522

错误代码:

ERROR in ./app/index.js
Module build failed: Error: C:/Users/wuhan001/WebstormProjects/reduxTest/app/index.js: Invalid mapping: {"generated":{"line":46,"column":153,"lastColumn":null},"source":n
me":null}
    at SourceMapGenerator_validateMapping [as _validateMapping] (C:\Users\wuhan001\WebstormProjects\reduxTest\node_modules\source-map\lib\source-map-generator.js:277:13)
    at SourceMapGenerator_addMapping [as addMapping] (C:\Users\wuhan001\WebstormProjects\reduxTest\node_modules\source-map\lib\source-map-generator.js:101:12)
    at C:\Users\wuhan001\WebstormProjects\reduxTest\node_modules\babel-core\lib\transformation\file\index.js:450:29
    at Array.forEach (native)
    at SourceMapConsumer_eachMapping [as eachMapping] (C:\Users\wuhan001\WebstormProjects\reduxTest\node_modules\source-map\lib\source-map-consumer.js:155:14)
    at C:\Users\wuhan001\WebstormProjects\reduxTest\node_modules\babel-core\lib\transformation\file\index.js:443:26
    at File.mergeSourceMap (C:\Users\wuhan001\WebstormProjects\reduxTest\node_modules\babel-core\lib\transformation\file\index.js:468:9)
    at File.generate (C:\Users\wuhan001\WebstormProjects\reduxTest\node_modules\babel-core\lib\transformation\file\index.js:659:25)
    at File.transform (C:\Users\wuhan001\WebstormProjects\reduxTest\node_modules\babel-core\lib\transformation\file\index.js:518:17)
    at C:\Users\wuhan001\WebstormProjects\reduxTest\node_modules\babel-core\lib\transformation\pipeline.js:49:19
 @ multi main

webpack配置:

var path = require('path');
var node_modules_dir = path.join(__dirname, 'node_modules');

var deps = [
    'react/dist/react.min.js'
];

var config = {
    entry: ['webpack-dev-server/client?http://0.0.0.0:8080', // WebpackDevServer host and port
        'webpack/hot/only-dev-server', path.resolve(__dirname, './app/index.js')],
    resolve: {
        alias: {},
        extensions: ['', '.js', '.jsx']
    },
    devtool: 'eval-source-map',
    output: {
        path: path.resolve(__dirname, './build'),
        filename: 'bundle.js'
    },
    module: {
        noParse: [],
        loaders: [{
            test: /\.js?$/,
            exclude: /(node_modules|bower_components)/,
            loaders: ['react-hot', 'babel']
        }, {
            test: /\.jsx?$/,
            exclude: /(node_modules|bower_components)/,
            loaders: ['react-hot', 'babel'],
        }, {
            test: /\.css$/,
            loader: 'style!css'
        }, {
            test: /\.less$/,
            loader: 'style!css!less'
        }]
    },
    devServer: {
        contentBase: "./build",
        noInfo: true, //  --no-info option
        hot: true,
        inline: true
    },
};

deps.forEach(function (dep) {
    var depPath = path.resolve(node_modules_dir, dep);
    config.resolve.alias[dep.split(path.sep)[0]] = depPath;
    config.module.noParse.push(depPath);
});

module.exports = config;
回复
阅读 6.2k
3 个回答
XWZy
  • 4
新手上路,请多包涵

请问解决了?

huimingli666
  • 2
新手上路,请多包涵

请问解决了吗

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
宣传栏