繁体   English   中英

NPM 卡在旧版本上?

[英]NPM stuck on an old version?

我正在关注前段时间录制的一些教程,它告诉我们将 npm 版本降级到 5.5.1 以避免任何差异(因为这是录制时的最新版本)。 所以我做了,使用经典

npm install -g npm@5.5.1 

但是,现在我卡住了,无法更新到实际的当前最新版本。 我试过npm install -g npm@latest ,我试过手动输入最新版本,我什至尝试卸载 Node 和 NPM,并安装最新的,从网站上新鲜,但无论出于什么原因,我的 npm 卡在 5.5 上。 1 再。 我该如何解决?

顺便说一句,我正在使用 Windows。 另外,我只是在学习 Node 和 NPM,所以我想我有可能错过了一些明显的解决方案?

编辑:每当我尝试安装某些东西时,我都会得到以下信息

npm WARN npm npm does not support Node.js v12.18.3 npm WARN npm You should probably upgrade to a newer version of node as we npm WARN npm can't make any promises that npm will work with this version. npm WARN npm Supported releases of Node.js are the latest release of 4, 6, npm WARN npm You can find the latest version at https://nodejs.org/ WARNING: You are likely using a version of node-tar or npm that is incompa with this version of Node.js. Please use either the version of npm that is bundled with Node.js, or a ve of npm (> 5.5.1 or < 5.4.0) or node-tar (> 4.0.1) that is compatible with s 9 and above.

然后是一长串错误,包括但不限于

1:000000013F8A5EBF napi_wrap + 114095 2:000000013F850B46 V8 ::基:: CPU :: has_sse + 66998 3:000000013F850EC1 V8 ::基:: CPU :: has_sse + 67889 4:000000013F78F187 RSA_meth_get_flags + 85639 5:000000014001AAE0 V8 ::内部: :Builtins::builtin_handle+323456

在您的项目根目录中,运行更新命令:

npm update

试试这个以管理员身份运行 PowerShell

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force 
npm install -g npm-windows-upgrade 
npm-windows-upgrade

请参阅此https://www.npmjs.com/package/npm-windows-upgrade或他们的 GitHub 存储以获得更多帮助

如果它没有帮助,试试这个

卸载节点(Settings -> Add or remove programs) ,然后导航到C:\\Users\\{User}\\AppData\\Roaming并删除npm and npm-cache folder and finally install node again (using the installer).

你错过了-g 你说:

我试过npm install npm@latest

但这不包括-g -g是关键,因为它会导致npm全局安装(最好的押韵)。 请参阅全局下载和安装软件包 您的第一个命令包含它,但不包含后续命令。

因此,您可能将npm安装为本地依赖项(您可能并不打算这样做)。 检查您的package.json并查看是否有任何npm列表。 如果您不直接使用npm运行时部分,请删除该依赖项,只需使用-g全局安装您想要的特定版本。

暂无
暂无

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

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