webpack SyntaxError:严格模式之外尚不支持块范围的声明(let,const,函数,类)

时间:2018-07-02 07:02:51

标签: javascript node.js webpack

我尝试将npm软件包hard-source-webpack-plugin添加到我的项目中。如文档中所述,我只应添加

var HardSourceWebpackPlugin = require('hard-source-webpack-plugin');

运行webpack时出现以下错误:

D:\Projects\MyProject\node_modules\hard-source-webpack-plugin\index.js:49
let ops = 0;
^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:404:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (D:\Projects\MyProject\webpack.config.js:6:31)
    at Module._compile (module.js:397:26)
    at Object.Module._extensions..js (module.js:404:10)
Process terminated with code 1.

我安装了最新的Node.js,当前版本为10.5.0。

0 个答案:

没有答案