简体   繁体   English

NPM 卡在旧版本上?

[英]NPM stuck on an old version?

I was following some tutorial that was recorded a while ago, and it said for us to downgrade our npm version to 5.5.1 to avoid any differences (since that was the newest version at the time of the recording).我正在关注前段时间录制的一些教程,它告诉我们将 npm 版本降级到 5.5.1 以避免任何差异(因为这是录制时的最新版本)。 So I did, using classic所以我做了,使用经典

npm install -g npm@5.5.1 

However, now I'm stuck, I can't update to the actual present day latest version.但是,现在我卡住了,无法更新到实际的当前最新版本。 I tried npm install -g npm@latest , I tried manually typing the latest version, I even tried uninstalling both Node and NPM, and installing the latest ones, fresh from the site, but for whatever reason my npm just gets stuck on 5.5.1 again.我试过npm install -g npm@latest ,我试过手动输入最新版本,我什至尝试卸载 Node 和 NPM,并安装最新的,从网站上新鲜,但无论出于什么原因,我的 npm 卡在 5.5 上。 1 再。 How do I fix this?我该如何解决?

I'm using Windows btw.顺便说一句,我正在使用 Windows。 Also, I'm just learning about Node and NPM, so I guess there is a chance I'm missing some obvious solution?另外,我只是在学习 Node 和 NPM,所以我想我有可能错过了一些明显的解决方案?

Edit: whenever I try to install something, I get the following编辑:每当我尝试安装某些东西时,我都会得到以下信息

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.

and after that a long list of errors, including, but not limited to然后是一长串错误,包括但不限于

1: 000000013F8A5EBF napi_wrap+114095 2: 000000013F850B46 v8::base::CPU::has_sse+66998 3: 000000013F850EC1 v8::base::CPU::has_sse+67889 4: 000000013F78F187 RSA_meth_get_flags+85639 5: 000000014001AAE0 v8::internal::Builtins::builtin_handle+323456 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

try this Run PowerShell as Administrator试试这个以管理员身份运行 PowerShell

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

refer to this https://www.npmjs.com/package/npm-windows-upgrade or their GitHub repo for more help请参阅此https://www.npmjs.com/package/npm-windows-upgrade或他们的 GitHub 存储以获得更多帮助

if it doesn't help, try this如果它没有帮助,试试这个

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

You are missing the -g .你错过了-g You said:你说:

I tried npm install npm@latest我试过npm install npm@latest

but that that doesn't include the -g .但这不包括-g The -g is key because it causes npm to be installed globally (best rhyme). -g是关键,因为它会导致npm全局安装(最好的押韵)。 See Downloading and installing packages globally .请参阅全局下载和安装软件包 Your first command includes it, but not the follow up.您的第一个命令包含它,但不包含后续命令。

Because of this, you probably install npm as a local dependency (which you probably didn't mean to do).因此,您可能将npm安装为本地依赖项(您可能并不打算这样做)。 Check your package.json and see if there is any listing of npm .检查您的package.json并查看是否有任何npm列表。 If you aren't directly using runtime pieces of npm , remove that dependency and just install the specific version you want globally with -g .如果您不直接使用npm运行时部分,请删除该依赖项,只需使用-g全局安装您想要的特定版本。

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

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