Javascript webpack SyntaxError:在严格模式外尚不支持块作用域声明(let、const、函数、类)

Javascript webpack SyntaxError:在严格模式外尚不支持块作用域声明(let、const、函数、类),javascript,node.js,webpack,Javascript,Node.js,Webpack,我已经尝试将npm包添加到我的项目中。如文件中所述,我只需添加 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 declaration

我已经尝试将npm包添加到我的项目中。如文件中所述,我只需添加

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.
D:\Projects\MyProject\node\u modules\hard source webpack plugin\index.js:49
设ops=0;
^^^
SyntaxError:在严格模式外尚不支持块作用域声明(let、const、函数、类)
在exports.runInThisContext(vm.js:53:16)
在模块处编译(Module.js:373:25)
在Object.Module.\u extensions..js(Module.js:404:10)
在Module.load(Module.js:343:32)
在Function.Module.\u加载(Module.js:300:12)
at Module.require(Module.js:353:17)
根据需要(内部/module.js:12:17)
反对。(D:\Projects\MyProject\webpack.config.js:6:31)
在模块处编译(Module.js:397:26)
在Object.Module.\u extensions..js(Module.js:404:10)
进程以代码1终止。

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

“我安装了最新的Node.jsm,当前版本为10.5.0。”如果您遇到该错误,则该错误不是您遇到该错误时正在运行的节点版本。您似乎安装了旧版本的Node,现在正在使用。@T.J.Crowder我已经卸载了以前的版本,在更新到新版本之前是
8.9.0
。有没有可能我可以查一下附近还有哪些版本?当然可以。如何这样做将取决于您的操作系统以及您如何安装早期版本。这是你必须在你这边完成的事情,我们在这里真的不能为你做太多。但是,例如,在*nix系统上,您可以使用
哪个节点
查看哪个节点是从给定的终端运行的,您可以使用
查找
查找其他副本,您可以查看网页包脚本,查看它如何确定要调用哪个节点(如果它不只是依赖路径中的一个)。您安装的节点版本应该无关紧要。如果执行
node-v
会为您提供所需的版本。快速修复方法是简单地在严格模式下运行代码…可能还会报告一个错误,他们应该添加
“使用严格”到他们模块的顶部。