简体   繁体   English

npm 不支持 Node.js v14.4.0

[英]npm does not support Node.js v14.4.0

everyone.每个人。

I am upgrading Node.js and npm in my Ubuntu 18.04.6 server, but I'm running into a strange problem.我正在我的 Ubuntu 18.04.6 服务器中升级 Node.js 和 npm,但我遇到了一个奇怪的问题。

I was using the process as indicated in the installation guides: To install Node.js version 17.2.0, I use我正在使用安装指南中指示的过程:要安装 Node.js 版本 17.2.0,我使用

curl -fsSL https://deb.nodesource.com/setup_17.x | sudo -E bash -
sudo apt-get install -y nodejs

Then, to install npm version, I use然后,要安装 npm 版本,我使用

npm install -g npm

However, after this, when I try to use npm to install modules, I get the warning但是,在此之后,当我尝试使用 npm 安装模块时,我收到警告

npm does not support Node.js v14.4.0 npm 不支持 Node.js v14.4.0
You should probably upgrade to a newer version of node as we您可能应该升级到更新版本的节点,因为我们
can't make any promises that npm will work with this version.无法保证 npm 将与此版本一起使用。

Checking the versions of node, I find that检查节点的版本,我发现

node --version

yields v14.4.0 , but产生v14.4.0 ,但是

nodejs --version

yields v17.2.0 .产生v17.2.0

How do I fix it so node will point to the latest version and/or so npm will use the correct version of node?如何修复它,以便节点指向最新版本和/或 npm 将使用正确版本的节点?

I had also tried a lot for upgrading node version from 14 to 18. But even after installing latest version and following various procedures my version of node was showing 14.4.0 only.我也尝试了很多将节点版本从 14 升级到 18。但即使在安装了最新版本并遵循各种程序之后,我的节点版本也只显示 14.4.0。 Luckily following three node version manager commands solved my problem on my ubuntu machine v20.04.4:幸运的是,遵循三个节点版本管理器命令解决了我在 ubuntu 机器 v20.04.4 上的问题:

1. curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
2. command -v nvm
3. nvm install node

Now check node has been updated to latest version and can be verified with node --version .现在检查节点已更新到最新版本,可以使用node --version进行验证。

If you still find an old version even on installing new latest/lts version, then check which node version is set as default with following command:如果即使在安装新的 latest/lts 版本时仍然发现旧版本,请使用以下命令检查哪个节点版本设置为默认值:

nvm ls

you will see green colored version text set with an arrow in front of it.您将看到绿色版本文本集,前面有一个箭头。 It will also show other versions which have installed recently like v16.15.0, v18.2.0, etc. Change the node version you want to set by following command:它还会显示最近安装的其他版本,如 v16.15.0、v18.2.0 等。通过以下命令更改要设置的节点版本:

nvm alias default v18.2.0

After this close the terminal and restart the new terminal and try checking node JS version.在此之后关闭终端并重新启动新终端并尝试检查节点 JS 版本。 Here you got you want..!!给你你想要的..!!

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

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