简体   繁体   English

使用g npm install npm @ latest -g更新节点软件包管理器并得到错误

[英]Used g npm install npm@latest -g to update Node Package Manager and getting error

I was trying to update my Node Package Manager using g npm install npm@latest -g in the terminal but when I tried to check if it was updated using npm --version or npm -v or even npm install, I get the following error: 我试图在终端中使用g npm install npm @ latest -g更新我的Node Package Manager,但是当我尝试检查是否使用npm --version或npm -v甚至npm install更新了它时,出现以下错误:

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:387:25)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:139:18)
at node.js:999:3

I had version 5.0.3 for NPM and now I can't run any npm commands. 我的NPM版本为5.0.3,现在我无法运行任何npm命令。 Can someone please help me remedy this error by uninstalling this latest version or anything to get this version to work. 有人可以通过卸载此最新版本或任何使该版本正常工作的方法来帮助我纠正此错误。

Block-scoped declarations not yet supported outside strict mode - Laravel Mix , check out this StackOverflow answer. 严格模式之外尚不支持块范围的声明-Laravel Mix ,请查看此StackOverflow答案。 The solution is pretty much to update Node, but I'll explain why. 解决方案几乎可以更新Node,但我将解释原因。 There's a new flavour of Javascript called ES6 (and above) that uses certain keywords that aren't found in your Node version. 有一种名为ES6(及更高版本)的新Javascript,它使用在Node版本中找不到的某些关键字。 the new NPM uses these keywords but your older version of Node can't interpret them. 新的NPM使用这些关键字,但是您的旧版Node无法解释它们。 Best option is to uninstall and get the latest version. 最好的选择是卸载并获取最新版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM