2017-04-12 58 views
0

,我发现了以下错误:如何关闭的WebPack掉毛

SyntaxError: arguments is a reserved word in strict mode 

试图做的时候:

console.log(arguments); 

如何关闭的WebPack掉毛?我的配置看起来像这样:

var plugins = [ 
    new webpack.LoaderOptionsPlugin({ 
     debug: true 
    }), 
    plugins.push(new webpack.DefinePlugin({ 
     'process.env': { 
      NODE_ENV: JSON.stringify('production') 
     } 
    })) 
    plugins.push(new webpack.optimize.UglifyJsPlugin()) 
]; 

webpack({ 
    entry: entry.path, 
    output: { 
     filename: output['file name'], 
     path: output.path 
    }, 
    resolve: { 
     modules: module.paths, 
     extensions: ['.js', '.jsx'] 
    }, 

    module: { 
     rules: [{ 
      test: /.jsx?$/, 
      exclude: /node_modules/, 
      use: [{ 
       loader: 'babel-loader', 
       options: { 
        babelrc: false, 
        presets: ['es2015', 'react'] 
       } 
      }] 
     }] 
    }, 
    resolveLoader: { 
     modules: loader.paths 
    }, 
    plugins: plugins, 
    stats: { 
     colors: true, 
     errorDetails: true, 
     modules: true, 
     modulesSort: "field", 
     reasons: true, 
    } 
}, function(err, stats) { 
    if (err) { 
     require('log')(err); 
     return; 
    } 

    const info = stats.toJson(); 
    if (stats.hasErrors()) { 
     require('log')(info.errors); 
    } 
    else { 
     require('log')(options.launcher + " compiled") 
    } 

    if (stats.hasWarnings()) { 
     require('log')(info.warnings) 
    } 
}); 

.... 话,这样我可以张贴此问题与出计算器给我,我的问题是,大部分代码.... 错误...

+0

难道你还发布您的package.json? –

回答

4

这是一个SyntaxError,这意味着你的代码不能编译。当你忘记输入花括号的一半时,会出现同样的错误。

这不是一个lint问题(代码样式)。

很可能您错误地将保留字arguments用作变量名称。将它重命名为其他内容。

运行代码咆哮,你可以看到你仍然得到一个没有webpack的错误。

"use strict"; 
 
var arguments = 1; 
 
console.log(arguments)

+0

是的..我有函数日志(参数){...}。我仍然不赞成这个事实,即停止编译...... –